
Border s
Every Swing component inherits a border pr operty fr om JComponent,soyou can
call
setBorder() to specify a Border object for a Swing component. This Border
object displays some kind of decoration around the outside of the component. The
javax.swing.border package contains this Border inter face and a number of use-
ful implementations of it. Table 3-1 lists the available border styles, and Figure 3-2
illustrates them.
Table 3−1: Swing Border Styles
Bor der Description
BevelBorder Gives the component a beveled edge that makes it appear
raised or lowered.
CompoundBorder Combines two other Border types to create a compound
border.
EmptyBorder A border with no appearance. This is a useful way to place
an empty margin around a component.
EtchedBorder Draws a line around the component, using a 3D effect that
makes the line appear etched into or raised out of the
surr ounding container.
LineBorder Draws a line, with a color and thickness you specify, around
the component.
MatteBorder Draws the border using a solid color or a tiled image. You
specify the border dimensions for all four sides.
SoftBevelBorder Like BevelBorder, but with somewhat more complex
graphics that give the bevel a softer edge.
TitledBorder A border that combines text with an EtchedBorder or any
other border you specify.
The Border implementations defined in javax.swing.border cover just about
every possible border you are likely to ...