Java Code Examples for javax.swing.border.TitledBorder#setTitleJustification()

The following examples show how to use javax.swing.border.TitledBorder#setTitleJustification() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainPanel.java    From java-swing-tips with MIT License 6 votes vote down vote up
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));
}
 
Example 2
Source File: ToolAdapterTabbedEditorDialog.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
@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;
}
 
Example 3
Source File: WizardManager.java    From ghidra with Apache License 2.0 5 votes vote down vote up
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());
	}
}
 
Example 4
Source File: IconView.java    From RobotBuilder with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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));
    }
}
 
Example 5
Source File: ToolAdapterTabbedEditorDialog.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example 6
Source File: DialogController.java    From mae-annotation with GNU General Public License v3.0 5 votes vote down vote up
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);
    }

}
 
Example 7
Source File: BalanceSheetPanel.java    From computational-economy with GNU General Public License v3.0 5 votes vote down vote up
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));
}
 
Example 8
Source File: ControlInputArea.java    From osp with GNU General Public License v3.0 5 votes vote down vote up
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;
}
 
Example 9
Source File: GUIOptionPrivateDNS.java    From PacketProxy with Apache License 2.0 4 votes vote down vote up
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;
}
 
Example 10
Source File: Gui.java    From ehacks-pro with GNU General Public License v3.0 4 votes vote down vote up
public Border customTitledBorder(String title, int align) {
    TitledBorder border = BorderFactory.createTitledBorder(title);
    border.setTitleJustification(align);
    return border;
}
 
Example 11
Source File: BorderDemo.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
void addCompForTitledBorder(TitledBorder border, String description, int justification, int position, Container container) {
    border.setTitleJustification(justification);
    border.setTitlePosition(position);
    addCompForBorder(border, description, container);
}
 
Example 12
Source File: ConnectDialog.java    From tn5250j with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);
}