Creating and Setting a MatteBorder from BorderFactory : MatteBorder « Swing « Java Tutorial

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.border.MatteBorder;

public class Main {
  public static void main(String[] argv) {
    ImageIcon icon = new ImageIcon("image.gif");
    MatteBorder matteBorder = (MatteBorder)BorderFactory.createMatteBorder(-1, -1, -1, -1, icon);
    JLabel component = new JLabel("label");


14.107.2.Color MatteBorderColor MatteBorder
14.107.3.Using Icon to create border: MatteBorderUsing Icon to create border: MatteBorder
14.107.4.Creating and Setting a MatteBorder from BorderFactory