TitledBorder: setTitleJustification(int pos) : TitledBorder « javax.swing.border « Java by API






TitledBorder: setTitleJustification(int pos)

import java.awt.Container;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.border.TitledBorder;

public class MainClass {

  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);

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

  }
}

           
       








Related examples in the same category

1.TitledBorder.ABOVE_BOTTOM
2.TitledBorder.ABOVE_TOP
3.TitledBorder.BELOW_BOTTOM
4.TitledBorder.BELOW_TOP
5.TitledBorder.BOTTOM
6.TitledBorder.CENTER
7.TitledBorder.LEFT
8.TitledBorder.RIGHT
9.TitledBorder.TOP
10.new TitledBorder(Border border, String title)
11.new TitledBorder(Border border, String title, int titleJustification, int titlePosition, Font titleFont, Color titleColor)
12.new TitledBorder(Border border, String title, int titleJustification, int titlePosition)
13.TitledBorder: setTitlePosition(int pos)