javax.swing.border.TitledBorder#setTitleJustification ( )源码实例Demo

下面列出了javax.swing.border.TitledBorder#setTitleJustification ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: java-swing-tips   文件: MainPanel.java
private MainPanel() {
  super(new GridLayout(2, 1, 5, 5));

  TitledBorder b1 = BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.GRAY), "TitledBorder");
  b1.setTitleJustification(TitledBorder.CENTER);

  JPanel p1 = new JPanel();
  p1.setBorder(b1);

  Border raisedBevel = BorderFactory.createRaisedBevelBorder();
  Border topLine = BorderFactory.createMatteBorder(10, 0, 0, 0, Color.GRAY.brighter());
  Border loweredBevel = BorderFactory.createLoweredBevelBorder();
  Border compound1 = BorderFactory.createCompoundBorder(raisedBevel, topLine);
  Border compound2 = BorderFactory.createCompoundBorder(compound1, loweredBevel);
  TitledBorder b2 = BorderFactory.createTitledBorder(compound2, "CompoundBorder");
  b2.setTitleJustification(TitledBorder.CENTER);

  JPanel p2 = new JPanel();
  p2.setBorder(b2);

  add(p1);
  add(p2);
  setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
  setPreferredSize(new Dimension(320, 240));
}
 
@Override
protected JPanel createPatternsPanel() {
    JPanel patternsPanel = new JPanel(new SpringLayout());
    TitledBorder titledBorder = BorderFactory.createTitledBorder(Bundle.CTL_Panel_OutputPattern_Border_TitleText());
    titledBorder.setTitleJustification(TitledBorder.CENTER);
    patternsPanel.setBorder(titledBorder);

    TextFieldEditor textEditor = new TextFieldEditor();
    addTextField(patternsPanel, textEditor, Bundle.CTL_Label_ProgressPattern(),
                 ToolAdapterConstants.PROGRESS_PATTERN, false, null);
    propertyContainer.getDescriptor(ToolAdapterConstants.PROGRESS_PATTERN)
            .setValidator(new RegexFieldValidator());
    addTextField(patternsPanel, textEditor, Bundle.CTL_Label_StepPattern(),
                 ToolAdapterConstants.STEP_PATTERN, false, null);
    propertyContainer.getDescriptor(ToolAdapterConstants.STEP_PATTERN)
            .setValidator(new RegexFieldValidator());
    addTextField(patternsPanel, textEditor, Bundle.CTL_Label_ErrorPattern(),
                 ToolAdapterConstants.ERROR_PATTERN, false, null);
    propertyContainer.getDescriptor(ToolAdapterConstants.ERROR_PATTERN)
            .setValidator(new RegexFieldValidator());

    SpringUtilities.makeCompactGrid(patternsPanel, 3, 2,
                                    DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING);

    return patternsPanel;
}
 
源代码3 项目: ghidra   文件: WizardManager.java
private void updateScrollPaneBorder(JPanel panel) {
	if (panel == null) {
		return;
	}

	scrollPane.setBackground(panel.getBackground());

	if (scrollPane.getVerticalScrollBar().isShowing()) {
		TitledBorder titledBorder =
			new TitledBorder(BorderFactory.createEmptyBorder(), "(scroll for more options)");

		Font font = titledBorder.getTitleFont();
		if (font == null) {
			// workaround for bug on Java 7
			font = titleLabel.getFont();
		}

		titledBorder.setTitleFont(font.deriveFont(10f));
		titledBorder.setTitleColor(Color.BLUE);
		titledBorder.setTitlePosition(TitledBorder.BOTTOM);
		titledBorder.setTitleJustification(TitledBorder.TRAILING);

		scrollPane.setBorder(titledBorder);
	}
	else {
		scrollPane.setBorder(BorderFactory.createEmptyBorder());
	}
}
 
源代码4 项目: RobotBuilder   文件: IconView.java
private IconSection(DefaultMutableTreeNode node) {
    //BorderFactory.createT
    setBorder(BorderFactory.createTitledBorder(node.getUserObject().toString()));
    TitledBorder border = ((TitledBorder) getBorder());
    border.setTitleFont(new Font("Arial", Font.BOLD, 12));
    border.setTitleJustification(TitledBorder.CENTER);

    setLayout(new GridLayout(0, 2, 5, 5));

    Enumeration children = node.children();
    while (children.hasMoreElements()) {
        PaletteComponent component = (PaletteComponent) ((DefaultMutableTreeNode) children.nextElement()).getUserObject();
        add(new PaletteIcon(component));
    }
}
 
private void addTab(JTabbedPane tabControl, String title, JPanel content) {
    JLabel tabText = new JLabel(title, JLabel.LEFT);
    tabText.setPreferredSize(new Dimension(6 * controlHeight, controlHeight));
    TitledBorder titledBorder = BorderFactory.createTitledBorder(title);
    titledBorder.setTitleJustification(TitledBorder.CENTER);
    content.setBorder(titledBorder);
    tabControl.addTab(null, content);
    tabControl.setTabComponentAt(tabControl.getTabCount() - 1, tabText);
}
 
源代码6 项目: mae-annotation   文件: DialogController.java
CreateLinkOptionPanel(TagType linkType, List<ExtentTag> argumentCandidates) throws MaeDBException {
    super();

    List<ArgumentType> argTypes = new ArrayList<>(linkType.getArgumentTypes());
    setLayout(new GridLayout(1, argTypes.size()));

    argumentsMap = new LinkedHashMap<>();

    int typeNum = 0;
    for (final ArgumentType type : argTypes) {
        final JComboBox<ExtentTag> candidates = new JComboBox<>();
        candidates.setFont(MaeStrings.UNICODE_FONT);
        candidates.addItem(null);
        for (ExtentTag tag : argumentCandidates) {
            candidates.addItem(tag);
        }
        candidates.addActionListener(event ->
                argumentsMap.put(type, (ExtentTag) candidates.getSelectedItem()));
        candidates.setSelectedIndex((typeNum++ % argumentCandidates.size()) + 1);
        JPanel comboPanel = new JPanel();
        comboPanel.add(candidates);
        TitledBorder titledBorder = BorderFactory.createTitledBorder(
                etched, type.getName());
        titledBorder.setTitleJustification(TitledBorder.CENTER);
        comboPanel.setBorder(titledBorder);
        add(comboPanel);
    }

}
 
源代码7 项目: computational-economy   文件: BalanceSheetPanel.java
public BalanceSheetPanel(final Currency referenceCurrency, final BalanceSheetTableModel balanceSheetTableModel,
		final String title) {
	this.balanceSheetTableModel = balanceSheetTableModel;
	setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
	final TitledBorder titleBorder = BorderFactory.createTitledBorder(title);
	titleBorder.setTitleJustification(TitledBorder.CENTER);
	setBorder(titleBorder);
	final JTable balanceSheetTable = new JTable(balanceSheetTableModel);
	this.add(new JScrollPane(balanceSheetTable));
}
 
源代码8 项目: osp   文件: ControlInputArea.java
protected java.awt.Component createVisual(Object _visual) {
  if(_visual instanceof ParsableTextArea) {
    inputarea = (ParsableTextArea) _visual;
  } else {
    inputarea = new ParsableTextArea();
    inputarea.setEditable(true);
  }
  pane = new javax.swing.JScrollPane(inputarea);
  etchedBorder = new EtchedBorder(EtchedBorder.LOWERED);
  titledBorder = new TitledBorder(etchedBorder, ""); //$NON-NLS-1$
  titledBorder.setTitleJustification(TitledBorder.CENTER);
  pane.setBorder(etchedBorder);
  return inputarea;
}
 
源代码9 项目: PacketProxy   文件: GUIOptionPrivateDNS.java
private JPanel createPanel(JCheckBox checkBox, JTextField text) throws Exception {
	auto = new JRadioButton(I18nString.get("Auto (Replace resolved IP with local IP of suitable NIC automatically)"), true);
	auto.setMinimumSize(new Dimension(Short.MAX_VALUE, auto.getMaximumSize().height));
	auto.addActionListener(this::radioButtonChangeHandler);
	manual = new JRadioButton(I18nString.get("Manual"), false);
	manual.addActionListener(this::radioButtonChangeHandler);

	ButtonGroup rewriteGroup = new ButtonGroup();
	rewriteGroup.add(auto);
	rewriteGroup.add(manual);

	JPanel manualPanel = new JPanel();
	manualPanel.setBackground(Color.WHITE);
	manualPanel.setLayout(new BoxLayout(manualPanel, BoxLayout.X_AXIS));
	manualPanel.add(manual);
	manualPanel.add(text);

	TitledBorder rewriteRuleBorder = new TitledBorder(I18nString.get("Rewrite Rule"));
	LineBorder inborder = new LineBorder(Color.BLACK, 1);
	rewriteRuleBorder.setBorder(inborder);
	rewriteRuleBorder.setTitleFont(FontManager.getInstance().getUIFont());
	rewriteRuleBorder.setTitleJustification(TitledBorder.LEFT);
	rewriteRuleBorder.setTitlePosition(TitledBorder.TOP);

	JPanel rewriteRule = new JPanel();
	rewriteRule.setLayout(new BoxLayout(rewriteRule, BoxLayout.Y_AXIS));
	rewriteRule.setBackground(Color.WHITE);
	rewriteRule.setBorder(rewriteRuleBorder);
	rewriteRule.add(auto);
	rewriteRule.add(manualPanel);
	rewriteRule.setMaximumSize(new Dimension(rewriteRule.getPreferredSize().width, rewriteRule.getMinimumSize().height));

	JPanel panel = new JPanel();
	panel.setBackground(Color.WHITE);
	panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
	panel.add(checkBox);
	panel.add(rewriteRule);
	panel.setAlignmentX(Component.LEFT_ALIGNMENT);

	return panel;
}
 
源代码10 项目: ehacks-pro   文件: Gui.java
public Border customTitledBorder(String title, int align) {
    TitledBorder border = BorderFactory.createTitledBorder(title);
    border.setTitleJustification(align);
    return border;
}
 
源代码11 项目: marathonv5   文件: BorderDemo.java
void addCompForTitledBorder(TitledBorder border, String description, int justification, int position, Container container) {
    border.setTitleJustification(justification);
    border.setTitlePosition(position);
    addCompForBorder(border, description, container);
}
 
源代码12 项目: tn5250j   文件: ConnectDialog.java
/**
 * Simple about the program ...
 */
private void createAboutPanel() {

  aboutPanel = new JPanel();

  JPanel contenpane = new JPanel();

  TitledBorder tb = BorderFactory.createTitledBorder("About");
  tb.setTitleJustification(TitledBorder.CENTER);

  contenpane.add(new JLabel("TN5250j"));
  contenpane.add(new JLabel("Version: " + TN5250jConstants.VERSION_INFO));

  contenpane.setLayout(new BoxLayout(contenpane, BoxLayout.Y_AXIS));

  aboutPanel.add(contenpane);
  aboutPanel.setBorder(tb);
}