Example usage for javax.swing.border TitledBorder setTitleJustification

List of usage examples for javax.swing.border TitledBorder setTitleJustification

Introduction

In this page you can find the example usage for javax.swing.border TitledBorder setTitleJustification.

Prototype

public void setTitleJustification(int titleJustification) 

Source Link

Document

Sets the title-justification of the titled border.

Usage

From source file:MainClass.java

public static void main(final String args[]) {
    JFrame frame = new JFrame("Justified Titled Borders");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    TitledBorder leftBorder = BorderFactory.createTitledBorder("Left");
    leftBorder.setTitleJustification(TitledBorder.LEFT);
    JButton leftButton = new JButton();
    leftButton.setBorder(leftBorder);// w  w w.j av  a  2 s  .  c  om

    Container contentPane = frame.getContentPane();
    contentPane.add(leftButton);
    frame.setSize(300, 200);
    frame.setVisible(true);

}

From source file:MainClass.java

public static void main(final String args[]) {
    JFrame frame = new JFrame("Justified Titled Borders");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    TitledBorder centerBorder = BorderFactory.createTitledBorder("Center");
    centerBorder.setTitleJustification(TitledBorder.CENTER);
    JButton centerButton = new JButton();
    centerButton.setBorder(centerBorder);

    Container contentPane = frame.getContentPane();
    contentPane.add(centerButton);//from www. ja  va  2s .  c  o m
    frame.setSize(300, 200);
    frame.setVisible(true);

}

From source file:TitledJustBorder.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Justified Titled Borders");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    TitledBorder leftBorder = BorderFactory.createTitledBorder("Left");
    leftBorder.setTitleJustification(TitledBorder.LEFT);

    JButton leftButton = new JButton();
    leftButton.setBorder(leftBorder);/*ww  w . jav  a  2s.com*/

    TitledBorder rightBorder = BorderFactory.createTitledBorder("Right");
    rightBorder.setTitleJustification(TitledBorder.RIGHT);

    JButton rightButton = new JButton();
    rightButton.setBorder(rightBorder);

    TitledBorder centerBorder = BorderFactory.createTitledBorder("Center");
    centerBorder.setTitleJustification(TitledBorder.CENTER);

    JButton centerButton = new JButton();
    centerButton.setBorder(centerBorder);
    Container contentPane = frame.getContentPane();
    contentPane.setLayout(new GridLayout(3, 1));
    contentPane.add(leftButton);
    contentPane.add(rightButton);
    contentPane.add(centerButton);
    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] argv) {
    LineBorder border = new LineBorder(Color.red);
    TitledBorder titledBorder = BorderFactory.createTitledBorder(border, "Title");

    // Or: DEFAULT_JUSTIFICATION, LEFT, RIGHT
    titledBorder.setTitleJustification(TitledBorder.CENTER);
}

From source file:net.minelord.gui.panes.IRCPane.java

public static void updateBounds() {
    if (topic.getText().length() == 0)
        showTopic = false;/*ww  w.  ja v  a 2  s. co m*/
    topic.setVisible(showTopic);
    userScroller.setVisible(showUserList);
    if (topic != null && !showTopic && !showUserList)
        scroller.setBounds(scrollerWithoutTopicWithoutUserlist);
    if (topic != null && !showTopic && showUserList) {
        scroller.setBounds(scrollerWithoutTopicWithUserlist);
        userScroller.setBounds(userScrollerWithoutTopic);
    }
    if (topic != null && showTopic && showUserList) {
        scroller.setBounds(scrollerWithTopicWithUserlist);
        userScroller.setBounds(userScrollWithTopic);
    }
    if (topic != null && showTopic && !showUserList)
        scroller.setBounds(scrollerWithTopicWithoutUserlist);
    if (topic != null && !showUserList) {
        TitledBorder title = BorderFactory
                .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), status);
        title.setTitleJustification(TitledBorder.RIGHT);
        scroller.setBorder(title);
    } else
        scroller.setBorder(
                BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), ""));
    userList.repaint();
    scroller.repaint();
}

From source file:BorderDemo.java

void addCompForTitledBorder(TitledBorder border, String description, int justification, int position,
        Container container) {/*w  w  w . j a v  a 2  s .  c  om*/
    border.setTitleJustification(justification);
    border.setTitlePosition(position);
    addCompForBorder(border, description, container);
}

From source file:com.floreantpos.bo.ui.explorer.ModifierExplorer.java

private JPanel buildSearchForm() {
    List<MenuModifierGroup> grpName;
    JPanel panel = new JPanel();
    panel.setLayout(new MigLayout("", "[][]30[][]30[]", "[]20[]")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

    JLabel nameLabel = new JLabel(Messages.getString("ModifierExplorer.3")); //$NON-NLS-1$
    JLabel groupLabel = new JLabel(Messages.getString("ModifierExplorer.4")); //$NON-NLS-1$
    final JTextField nameField = new JTextField(15);
    grpName = MenuModifierGroupDAO.getInstance().findAll();
    final JComboBox cbGroup = new JComboBox();
    cbGroup.addItem(Messages.getString("ModifierExplorer.5")); //$NON-NLS-1$
    for (MenuModifierGroup s : grpName) {
        cbGroup.addItem(s);/*  w w w.  j av  a2  s. co  m*/
    }

    JButton searchBttn = new JButton(Messages.getString("ModifierExplorer.6")); //$NON-NLS-1$
    panel.add(nameLabel, "align label"); //$NON-NLS-1$
    panel.add(nameField);
    panel.add(groupLabel);
    panel.add(cbGroup);
    panel.add(searchBttn);

    TitledBorder title;
    Border loweredetched;
    loweredetched = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
    title = BorderFactory.createTitledBorder(loweredetched, Messages.getString("ModifierExplorer.8")); //$NON-NLS-1$
    title.setTitleJustification(TitledBorder.LEFT);
    panel.setBorder(title);
    searchBttn.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            List<MenuModifier> modifierList;
            String txName = nameField.getText();
            Object selectedItem = cbGroup.getSelectedItem();
            if (selectedItem instanceof MenuModifierGroup) {
                modifierList = ModifierDAO.getInstance().findModifier(txName, (MenuModifierGroup) selectedItem);
            } else {
                modifierList = ModifierDAO.getInstance().findModifier(txName, null);
            }

            setModifierList(modifierList);
        }
    });
    return panel;
}

From source file:com.floreantpos.bo.ui.explorer.MenuItemExplorer.java

private JPanel buildSearchForm() {
    JPanel panel = new JPanel();
    panel.setLayout(new MigLayout("", "[][]15[][]15[][]15[]", "[]5[]")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

    JLabel lblOrderType = new JLabel(Messages.getString("MenuItemExplorer.4")); //$NON-NLS-1$
    cbOrderTypes = new JComboBox();

    cbOrderTypes.addItem(Messages.getString("MenuItemExplorer.5")); //$NON-NLS-1$
    cbOrderTypes.addItem("<None>");

    List<OrderType> orderTypes = Application.getInstance().getOrderTypes();
    for (OrderType orderType : orderTypes) {
        cbOrderTypes.addItem(orderType);
    }/*from w  w w  .j a  v a2 s  .  c  o  m*/

    JLabel lblName = new JLabel(Messages.getString("MenuItemExplorer.0")); //$NON-NLS-1$
    JLabel lblGroup = new JLabel(Messages.getString("MenuItemExplorer.1")); //$NON-NLS-1$
    tfName = new JTextField(15);

    try {

        List<MenuGroup> menuGroupList = MenuGroupDAO.getInstance().findAll();

        cbGroup = new JComboBox();

        cbGroup.addItem(Messages.getString("MenuItemExplorer.2")); //$NON-NLS-1$
        cbGroup.addItem("<None>");
        for (MenuGroup s : menuGroupList) {
            cbGroup.addItem(s);
        }

        JButton searchBttn = new JButton(Messages.getString("MenuItemExplorer.3")); //$NON-NLS-1$

        panel.add(lblName, "align label"); //$NON-NLS-1$
        panel.add(tfName);
        panel.add(lblGroup);
        panel.add(cbGroup);
        panel.add(lblOrderType);
        panel.add(cbOrderTypes);
        panel.add(searchBttn);

        Border loweredetched = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
        TitledBorder title = BorderFactory.createTitledBorder(loweredetched, "Search"); //$NON-NLS-1$
        title.setTitleJustification(TitledBorder.LEFT);
        panel.setBorder(title);

        searchBttn.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                searchItem();
            }
        });

        tfName.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                searchItem();
            }
        });

    } catch (Throwable x) {
        BOMessageDialog.showError(POSConstants.ERROR_MESSAGE, x);
    }

    return panel;
}

From source file:JXTransformer.java

private JPanel createStressTestPanel() {
        JPanel panel = new JPanel();
        TitledBorder titledBorder = BorderFactory.createTitledBorder("Stress test (with tooltips)");
        titledBorder.setTitleJustification(TitledBorder.CENTER);
        panel.setBorder(titledBorder);//from   w  w  w .  jav  a  2  s.  c  o  m
        JButton lowerButton = new JButton("Button");
        lowerButton.setLayout(new FlowLayout());
        lowerButton.setToolTipText("Lower button");
        JButton middleButton = new JButton();
        middleButton.setToolTipText("Middle button");
        middleButton.setLayout(new FlowLayout());
        lowerButton.add(middleButton);
        JButton upperButton = new JButton("Upper button");
        upperButton.setToolTipText("Upper button");
        middleButton.add(upperButton);
        panel.add(createTransformer(lowerButton));
        return panel;
    }

From source file:JXTransformer.java

private JPanel createDemoPanel() {
        JPanel buttonPanel = new JPanel(new GridLayout(3, 2));
        TitledBorder titledBorder = BorderFactory.createTitledBorder("Try three sliders below !");
        Font titleFont = titledBorder.getTitleFont();
        titledBorder.setTitleFont(titleFont.deriveFont(titleFont.getSize2D() + 10));
        titledBorder.setTitleJustification(TitledBorder.CENTER);
        buttonPanel.setBorder(titledBorder);
        JButton b = new JButton("JButton");
        b.setPreferredSize(new Dimension(100, 50));
        buttonPanel.add(createTransformer(b));

        Vector<String> v = new Vector<String>();
        v.add("One");
        v.add("Two");
        v.add("Three");
        JList list = new JList(v);
        buttonPanel.add(createTransformer(list));

        buttonPanel.add(createTransformer(new JCheckBox("JCheckBox")));

        JSlider slider = new JSlider(0, 100);
        slider.setLabelTable(slider.createStandardLabels(25, 0));
        slider.setPaintLabels(true);// w  w  w . j a v  a2  s . com
        slider.setPaintTicks(true);
        slider.setMajorTickSpacing(10);
        buttonPanel.add(createTransformer(slider));

        buttonPanel.add(createTransformer(new JRadioButton("JRadioButton")));
        final JLabel label = new JLabel("JLabel");
        label.addMouseListener(new MouseAdapter() {
            public void mouseEntered(MouseEvent e) {
                Font font = label.getFont();
                label.setFont(font.deriveFont(font.getSize2D() + 10));
            }

            public void mouseExited(MouseEvent e) {
                Font font = label.getFont();
                label.setFont(font.deriveFont(font.getSize2D() - 10));
            }
        });
        buttonPanel.add(createTransformer(label));

        return buttonPanel;
    }