import javax.swing.border.TitledBorder; static JPanel centerSection(JPanel section) { if (section != null) swing { ((TitledBorder) section.getBorder()).setTitleJustification(TitledBorder.CENTER); } ret section; }