Nested TitiledBorder : TitiledBorder « Swing « Java Tutorial






Nested TitiledBorder
import java.awt.BorderLayout;
import java.awt.Container;

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

public class DoubleTitle {
  public static void main(String args[]) {
    JFrame frame = new JFrame("Double Title");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    
    TitledBorder topBorder = BorderFactory.createTitledBorder("Top");
    topBorder.setTitlePosition(TitledBorder.TOP);
    
    TitledBorder doubleBorder = new TitledBorder(topBorder, "Bottom", TitledBorder.RIGHT,
        TitledBorder.BOTTOM);
    
    JButton doubleButton = new JButton();
    doubleButton.setBorder(doubleBorder);
    
    Container contentPane = frame.getContentPane();
    contentPane.add(doubleButton, BorderLayout.CENTER);
    frame.setSize(300, 100);
    frame.setVisible(true);
  }
}








14.101.TitiledBorder
14.101.1.Creating TitledBorder through its constructors and helper method from BorderFactory
14.101.2.Nested TitiledBorderNested TitiledBorder
14.101.3.Setting TitiledBorder DirectionSetting TitiledBorder Direction
14.101.4.Set title position
14.101.5.TitleBorder Title PositionTitleBorder Title Position
14.101.6.TitledBorder based on LineBorderTitledBorder based on LineBorder
14.101.7.TitleBorder JustificationTitleBorder Justification
14.101.8.Create a title border from another border
14.101.9.Change border text Justification alignment style
14.101.10.Customizing TitledBorder Look and Feel