Java Reference
In-Depth Information
■
Tip
To reduce screen redrawing, it's better to modify the properties of a titled border prior to placing the
border around a component.
Text justification of the title string within a
TitledBorder
is specified by one of four class
constants:
•
CENTER
: Place the title in the center.
•
DEFAULT_JUSTIFICATION
: Use the default setting to position the text. The value is equivalent
to
LEFT
.
•
LEFT
: Place the title on the left edge.
•
RIGHT
: Place the title on the right edge.
Figure 7-13 shows the same
TitledBorder
with three different justifications.
Figure 7-13.
Title justifications
You can position title strings in any one of six different locations, as specified by one of
seven class constants:
•
ABOVE_BOTTOM
: Place the title above the bottom line.
•
ABOVE_TOP
: Place the title above the top line.
•
BELOW_BOTTOM
: Place the title below the bottom line.
•
BELOW_TOP
: Place the title below the top line.
•
BOTTOM
: Place the title on the bottom line.
•
DEFAULT_POSITION
: Use the default setting to place the text. This value is equivalent to
TOP
.
•
TOP
: Place the title on the top line.
Figure 7-14 shows the six different positions available for the title on a
TitledBorder
.