Java examples for Swing:Border
use Title Border on JComponent
//package com.java2s; import javax.swing.BorderFactory; import javax.swing.JComponent; import javax.swing.border.Border; public class Main { public static void useTitleBorder(JComponent comp, String title) { comp.setBorder(BorderFactory.createTitledBorder(title)); }//from ww w .j a va 2s .c o m public static void useTitleBorder(JComponent comp, String title, int margin) { useTitleBorder(comp, title, margin, margin); } public static void useTitleBorder(JComponent comp, String title, int topBottom, int leftRight) { useTitleBorder(comp, title, topBottom, leftRight, topBottom, leftRight); } public static void useTitleBorder(JComponent comp, String title, int top, int left, int bottom, int right) { comp.setBorder(BorderFactory.createTitledBorder( BorderFactory.createEmptyBorder(top, left, bottom, right), title)); } public static Border createEmptyBorder(int margin) { return BorderFactory.createEmptyBorder(margin, margin, margin, margin); } }