Java Reference
In-Depth Information
public CompoundBorder()
public static CompoundBorder createCompoundBorder()
public CompoundBorder(Border outside, Border inside)
Border compoundBorder = new CompoundBorder(lineBorder, matteBorder);
public static CompoundBorder createCompoundBorder(Border outside, Border inside)
Border compoundBorder = BorderFactory.createCompoundBorder(lineBorder,
matteBorder);
■
Tip
Keep in mind that
CompoundBorder
is itself a
Border
, so you can combine multiple borders into one
border many levels deep.
The opacity of a compound border depends on the opacity of the contained borders.
If both contained borders are opaque, so is the compound border. Otherwise, a compound
border is considered transparent.
Configuring Properties
In addition to the
borderOpaque
property inherited from
AbstractBorder
, Table 7-2 lists the two
read-only properties
CompoundBorder
adds.
Table 7-2.
CompoundBorder Properties
Property Name
Data Type
Access
borderOpaque
boolean
Read-only
insideBorder
Border
Read-only
outsideBorder
Border
Read-only
TitledBorder Class
Probably the most interesting border,
TitledBorder
can also be the most complicated to use. The
titled border allows you to place a text string around a component. In addition to surrounding a
single component, you can place a titled border around a group of components, like
JRadioButton
objects, as long as they're placed within a container such as a
JPanel
. The
TitledBorder
can be
difficult to use, but there are several ways to simplify its usage. Figure 7-12 shows both a simple
titled border and one that's a little more complex.