MatteBorder : MatteBorder « Swing « Java Tutorial






  1. A matte border displays a matte pattern.
  2. The matte pattern is created by using either a solid color or an icon.
  3. Solid matte borders are created by using the specified color.
  4. Tiled matte borders are created by using an icon that displays a matte picture.

The following constructors create a matte border:

public MatteBorder(int top, int left, int bottom, int right, Color color)   
  public MatteBorder(int top, int left, int bottom, int right, Icon tileIcon)   
  public MatteBorder(Icon tileIcon)
public MatteBorder(int top, int left, int bottom, int right, Color color)
Border matteBorder = new MatteBorder(5, 10, 5, 10, Color.GREEN);


public MatteBorder(int top, int left, int bottom, int right, Icon icon)
Icon diamondIcon = new DiamondIcon(Color.RED);
Border matteBorder = new MatteBorder(5, 10, 5, 10, diamondIcon);


public MatteBorder(Icon icon)
Icon diamondIcon = new DiamondIcon(Color.RED);
Border matteBorder = new MatteBorder(diamondIcon);
public MatteBorder(Insets insets, Color color)
Insets insets = new Insets(5, 10, 5, 10);
Border matteBorder = new MatteBorder(insets, Color.RED);


public MatteBorder(Insets insets, Icon icon)
Insets insets = new Insets(5, 10, 5, 10);
Icon diamondIcon = new DiamondIcon(Color.RED);
Border matteBorder = new MatteBorder(insets, diamondIcon);


public static MatteBorder createMatteBorder(int top, int left, int bottom, int right, Color color)
Border matteBorder = BorderFactory.createMatteBorder(5, 10, 5, 10, Color.GREEN);


public static MatteBorder createMatteBorder(int top, int left, int bottom, int right, Icon icon)
Icon diamondIcon = new DiamondIcon(Color.RED);
Border matteBorder = BorderFactory.createMatteBorder(5, 10, 5, 10, diamondIcon);








14.107.MatteBorder
14.107.1.MatteBorder
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