O'Reilly logo

Java Swing by Dave Wood, Marc Loy, Robert Eckstein

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The CompoundBorder Class

You can combine two borders to create more eye-catching displays with the CompoundBorder class. The insets of both borders are added together to form the insets of the resulting compound border object. The component renders the outside border first, followed by the inside border. You can compound borders recursively so that any number of borders can be embedded inside of a CompoundBorder object:

CompoundBorder comp = new CompoundBorder(
                        new CompoundBorder(new EtchedBorder(),
                                           new EmptyBorder(10, 10, 10, 10)),
                        new MatteBorder(20, 20, 20, 20, Color.red)
                      );

The preceding code yields the border in Figure 13.14.

A compound border

Figure 13-14. A compound border

Properties

Table 13.14 lists the properties of the CompoundBorder class. The insideBorder and outsideBorder properties hold the borders that are combined. If both of the borders in the compound border are opaque, the borderOpaque property is set to true. Otherwise, the property is false.

Table 13-14. CompoundBorder Properties

Property

Data Type

get

is

set

bound

Default Value

borderOpaque*

boolean

 

•

  

insideBorder

Border

•

   

null

outsideBorder

Border

•

   

null

Constructors

public CompoundBorder()

Initializes a default compound border with no outside and inside borders. Because there are no “set” accessors for either border property, you probably won’t ever need to invoke this ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required