Here you can find the source of setBorder(Container panel, String title)
static void setBorder(Container panel, String title)
//package com.java2s; //License from project: Open Source License import java.awt.Container; import javax.swing.BorderFactory; import javax.swing.JPanel; public class Main { static void setBorder(Container panel, String title) { if (panel instanceof JPanel) { ((JPanel) panel).setBorder(BorderFactory.createTitledBorder(title)); }/*from w ww .j a v a 2 s .c o m*/ } }