Create a title border from another border : TitiledBorder « Swing « Java Tutorial

import java.awt.Color;

import javax.swing.BorderFactory;
import javax.swing.border.LineBorder;
import javax.swing.border.TitledBorder;

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

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