Java Swing Empty Border addBorder(JComponent target, Border add)

Here you can find the source of addBorder(JComponent target, Border add)

Description

add Border

License

LGPL

Declaration

public static void addBorder(JComponent target, Border add) 

Method Source Code

//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);
    }
}

Related

  1. addBorderSpaces(JComponent com)
  2. addEmptyBorder(JComponent c, int i)
  3. addMarginAndBorder(JComponent component, int margin)
  4. blankBorder(int top, int left, int bottom, int right)