Example usage for javax.swing.border TitledBorder ABOVE_BOTTOM

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

Introduction

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

Prototype

int ABOVE_BOTTOM

To view the source code for javax.swing.border TitledBorder ABOVE_BOTTOM.

Click Source Link

Document

Position the title above the border's bottom line.

Usage

From source file:MainClass.java

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

    TitledBorder aboveBottomBorder = BorderFactory.createTitledBorder("AboveBottom");
    aboveBottomBorder.setTitlePosition(TitledBorder.ABOVE_BOTTOM);
    JButton aboveBottomButton = new JButton();
    aboveBottomButton.setBorder(aboveBottomBorder);

    Container contentPane = frame.getContentPane();
    contentPane.add(aboveBottomButton);//  www  .ja  v  a2s . c o m
    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:ATitledBorder.java

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

    Border thisBorder = BorderFactory.createTitledBorder("Easy");

    Border thatBorder1 = new LineBorder(Color.RED);
    Border thatBorder2 = new TitledBorder(thatBorder1, "Harder");

    Font font = new Font("Serif", Font.ITALIC, 12);
    Border thatBorder = new TitledBorder(thatBorder2, "Harder", TitledBorder.LEFT, TitledBorder.ABOVE_BOTTOM,
            font, Color.RED);/*from  w w  w  .ja v a2s .c om*/

    JButton thisButton = new JButton("Easy");
    thisButton.setBorder(thisBorder);

    JButton thatButton = new JButton("Harder");
    thatButton.setBorder(thatBorder);

    Container contentPane = frame.getContentPane();
    contentPane.setLayout(new GridLayout(1, 2));
    contentPane.add(thisButton);
    contentPane.add(thatButton);
    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:ATitledBorder.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Titled Borders");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Border thisBorder = BorderFactory.createTitledBorder("Easy");
    Icon thatIcon = new ImageIcon("diamond.gif");
    Border thatBorder1 = new MatteBorder(18, 20, 18, 20, thatIcon);
    Border thatBorder2 = new TitledBorder(thatBorder1, "Harder");
    Font font = new Font("Serif", Font.ITALIC, 12);
    Border thatBorder = new TitledBorder(thatBorder2, "Harder", TitledBorder.LEFT, TitledBorder.ABOVE_BOTTOM,
            font, Color.red);/*from  w ww  .ja  va2s  .  c o m*/
    JButton thisButton = new JButton("Easy");
    thisButton.setBorder(thisBorder);
    JButton thatButton = new JButton("Harder");
    thatButton.setBorder(thatBorder);
    Container contentPane = frame.getContentPane();
    contentPane.setLayout(new GridLayout(1, 2));
    contentPane.add(thisButton);
    contentPane.add(thatButton);
    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(String[] a) {
    JFrame frame = new JFrame("Titled Borders");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Border thisBorder = BorderFactory.createTitledBorder("Easy");
    Icon thatIcon = MetalIconFactory.getFileChooserHomeFolderIcon();

    Border thatBorder1 = new MatteBorder(18, 20, 18, 20, thatIcon);
    Border thatBorder2 = new TitledBorder(thatBorder1, "Harder");

    Font font = new Font("Serif", Font.ITALIC, 12);
    Border thatBorder = new TitledBorder(thatBorder2, "Hardest", TitledBorder.LEFT, TitledBorder.ABOVE_BOTTOM,
            font, Color.RED);/*from  w  w  w .j  av a 2s.  c  o  m*/

    JButton thisButton = new JButton("Easy");
    thisButton.setBorder(thisBorder);
    JButton thatButton = new JButton("Harder");
    thatButton.setBorder(thatBorder);
    Container contentPane = frame.getContentPane();
    contentPane.setLayout(new GridLayout(1, 2));
    contentPane.add(thisButton);
    contentPane.add(thatButton);
    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:TitledPostBorder.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Positioned Titled Borders");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    TitledBorder aboveTopBorder = BorderFactory.createTitledBorder("AboveTop");
    aboveTopBorder.setTitlePosition(TitledBorder.ABOVE_TOP);
    JButton aboveTopButton = new JButton();
    aboveTopButton.setBorder(aboveTopBorder);
    TitledBorder topBorder = BorderFactory.createTitledBorder("Top");
    topBorder.setTitlePosition(TitledBorder.TOP);
    JButton topButton = new JButton();
    topButton.setBorder(topBorder);//w ww .  j a v a 2s . c o m
    TitledBorder belowTopBorder = BorderFactory.createTitledBorder("BelowTop");
    belowTopBorder.setTitlePosition(TitledBorder.BELOW_TOP);
    JButton belowTopButton = new JButton();
    belowTopButton.setBorder(belowTopBorder);
    TitledBorder aboveBottomBorder = BorderFactory.createTitledBorder("AboveBottom");
    aboveBottomBorder.setTitlePosition(TitledBorder.ABOVE_BOTTOM);
    JButton aboveBottomButton = new JButton();
    aboveBottomButton.setBorder(aboveBottomBorder);
    TitledBorder bottomBorder = BorderFactory.createTitledBorder("Bottom");
    bottomBorder.setTitlePosition(TitledBorder.BOTTOM);
    JButton bottomButton = new JButton();
    bottomButton.setBorder(bottomBorder);
    TitledBorder belowBottomBorder = BorderFactory.createTitledBorder("BelowBottom");
    belowBottomBorder.setTitlePosition(TitledBorder.BELOW_BOTTOM);
    JButton belowBottomButton = new JButton();
    belowBottomButton.setBorder(belowBottomBorder);
    Container contentPane = frame.getContentPane();
    contentPane.setLayout(new GridLayout(3, 2));
    contentPane.add(aboveTopButton);
    contentPane.add(aboveBottomButton);
    contentPane.add(topButton);
    contentPane.add(bottomButton);
    contentPane.add(belowTopButton);
    contentPane.add(belowBottomButton);
    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:TitledPostBorder.java

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

    TitledBorder aboveTopBorder = BorderFactory.createTitledBorder("AboveTop");
    aboveTopBorder.setTitlePosition(TitledBorder.ABOVE_TOP);
    JButton aboveTopButton = new JButton();
    aboveTopButton.setBorder(aboveTopBorder);

    TitledBorder topBorder = BorderFactory.createTitledBorder("Top");
    topBorder.setTitlePosition(TitledBorder.TOP);
    JButton topButton = new JButton();
    topButton.setBorder(topBorder);//from w  ww.  j  a  v a  2  s  .  c  om

    TitledBorder belowTopBorder = BorderFactory.createTitledBorder("BelowTop");
    belowTopBorder.setTitlePosition(TitledBorder.BELOW_TOP);
    JButton belowTopButton = new JButton();
    belowTopButton.setBorder(belowTopBorder);

    TitledBorder aboveBottomBorder = BorderFactory.createTitledBorder("AboveBottom");
    aboveBottomBorder.setTitlePosition(TitledBorder.ABOVE_BOTTOM);
    JButton aboveBottomButton = new JButton();
    aboveBottomButton.setBorder(aboveBottomBorder);

    TitledBorder bottomBorder = BorderFactory.createTitledBorder("Bottom");
    bottomBorder.setTitlePosition(TitledBorder.BOTTOM);
    JButton bottomButton = new JButton();
    bottomButton.setBorder(bottomBorder);

    TitledBorder belowBottomBorder = BorderFactory.createTitledBorder("BelowBottom");
    belowBottomBorder.setTitlePosition(TitledBorder.BELOW_BOTTOM);
    JButton belowBottomButton = new JButton();
    belowBottomButton.setBorder(belowBottomBorder);

    Container contentPane = frame.getContentPane();
    contentPane.setLayout(new GridLayout(3, 2));
    contentPane.add(aboveTopButton);
    contentPane.add(aboveBottomButton);
    contentPane.add(topButton);
    contentPane.add(bottomButton);
    contentPane.add(belowTopButton);
    contentPane.add(belowBottomButton);
    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:Main.java

public Main() {
    getContentPane().setLayout(new FlowLayout());
    JLabel labelTwo = new JLabel("www.java2s.com");
    labelTwo.setBorder(BorderFactory.createEtchedBorder());

    add(labelTwo);// w  w w.  j  av a  2s .  c o  m

    JLabel labelFour = new JLabel("TitledBorder");
    labelFour.setBorder(BorderFactory.createTitledBorder(
            BorderFactory.createMatteBorder(10, 10, 10, 10, Color.pink), "Title", TitledBorder.ABOVE_BOTTOM,
            TitledBorder.BOTTOM, new Font("font name", Font.BOLD, 19)));
    add(labelFour);

}

From source file:Main.java

public Main() {
    getContentPane().setLayout(new FlowLayout());
    JLabel labelTwo = new JLabel("www.java2s.com");
    labelTwo.setBorder(BorderFactory.createEtchedBorder());

    add(labelTwo);/*from ww w . j  a  v  a 2  s  .co m*/

    JLabel labelFour = new JLabel("TitledBorder");
    labelFour.setBorder(BorderFactory.createTitledBorder(
            BorderFactory.createMatteBorder(10, 10, 10, 10, Color.pink), "Title", TitledBorder.ABOVE_BOTTOM,
            TitledBorder.BOTTOM, new Font("font name", Font.BOLD, 19), Color.BLACK));
    add(labelFour);

}