Java Reference
In-Depth Information
Figure 7-9. MatteBorder color sample
The second variety uses an Icon tiled throughout the border area. This Icon could be an
ImageIcon , if created from an Image object, or it could be one you create yourself by imple-
menting the Icon interface. Figure 7-10 demonstrates both implementations.
Figure 7-10. MatteBorder icon samples
Tip When tiling an icon, the right and bottom areas may not look very attractive if the border size,
component size, and icon size fail to mesh well.
There are seven constructors and two factory methods of BorderFactory for creating
MatteBorder objects:
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);
 
Search WWH ::




Custom Search