Here you can find the source of setTitleBorder(JComponent pane, String title)
public static void setTitleBorder(JComponent pane, String title)
//package com.java2s; /*/*from w w w . jav a 2s .c o m*/ * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc. * All rights reserved. This program is made available under the terms of the * Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html * Contributors: * General Robotix Inc. * National Institute of Advanced Industrial Science and Technology (AIST) */ import java.awt.Color; import javax.swing.JComponent; import javax.swing.border.LineBorder; import javax.swing.border.TitledBorder; public class Main { public static void setTitleBorder(JComponent pane, String title) { if (title != null) { pane.setBorder(new TitledBorder(new LineBorder(Color.BLACK), title, TitledBorder.LEFT, TitledBorder.TOP)); } else { pane.setBorder(new LineBorder(Color.BLACK)); } } }