Java Reference
In-Depth Information
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);
Each allows you to customize what will be matted within the border area. When tiling an
Icon , if you don't specify the border insets size, the actual icon dimensions will be used.
CompoundBorder Class
After EmptyBorder , the compound border is probably one of the simplest predefined borders to
use. It takes two existing borders and combines them, using the Composite design pattern, into
a single border. A Swing component can have only one border associated with it, therefore, the
CompoundBorder allows you to combine borders before associating them with a component.
Figure 7-11 shows two examples of CompoundBorder in action. The border on the left is a beveled,
line border. The one on the right is a six-line border, with several borders combined together.
Figure 7-11. CompoundBorder samples
Creating Compound Borders
There are two constructors for CompoundBorder and two factory methods that BorderFactory
offers for creating CompoundBorder objects (the no-argument constructor and factory methods
are completely useless here, because there are no setter methods to later change the compounded
borders, so no source examples are shown for them):
 
Search WWH ::




Custom Search