use Empty Border on JComponent - Java Swing

Java examples for Swing:Border

Description

use Empty Border on JComponent

Demo Code


//package com.java2s;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.border.Border;

public class Main {
    public static void useEmptyBorder(JComponent comp, int top, int left,
            int bottom, int right) {
        comp.setBorder(BorderFactory.createEmptyBorder(top, left, bottom,
                right));//from   w w w  .  j  ava2  s  .  c o  m
    }

    public static void useEmptyBorder(JComponent comp, int margin) {
        useEmptyBorder(comp, margin, margin, margin, margin);
    }

    public static Border createEmptyBorder(int margin) {
        return BorderFactory.createEmptyBorder(margin, margin, margin,
                margin);
    }
}

Related Tutorials