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(Color.red); TitledBorder titledBorder = BorderFactory.createTitledBorder(border, "Title"); // Or: DEFAULT_JUSTIFICATION, LEFT, RIGHT titledBorder.setTitleJustification(TitledBorder.CENTER); } }