Here you can find the source of addBorder(JComponent target, Border add)
public static void addBorder(JComponent target, Border add)
//package com.java2s; //License from project: LGPL import java.awt.*; import javax.swing.*; import javax.swing.border.Border; public class Main { public static void addBorder(JComponent target, Border add) { addBorder(target, add, false);//from w ww.j ava2s .com } public static void addBorder(JComponent target, Border add, boolean bInsert) { if (target.getBorder() != null) { if (!bInsert) target.setBorder(BorderFactory.createCompoundBorder(add, target.getBorder())); else target.setBorder(BorderFactory.createCompoundBorder( target.getBorder(), add)); } else target.setBorder(add); } public static void addBorder(JComponent target, Insets insets) { Border add = BorderFactory.createEmptyBorder(insets.top, insets.left, insets.bottom, insets.right); addBorder(target, add); } }