Java Reference
In-Depth Information
12.11.2 Alignments
Horizontal alignment specifies how the icon and text are placed horizontally on a button. You can
set the horizontal alignment using setHorizontalAlignment(int) with one of the five con-
stants LEADING , LEFT , CENTER , RIGHT , or TRAILING , as shown in Figure 12.18. At present,
LEADING and LEFT are the same, and TRAILING and RIGHT are the same. Future implementa-
tion may distinguish them. The default horizontal alignment is AbstractButton.CENTER .
horizontal alignment
Horizontally left
Horizontally center
Horizontally right
F IGURE 12.18
You can specify how the icon and text are placed on a button horizontally.
Vertical alignment specifies how the icon and text are placed vertically on a button. You
can set the vertical alignment using setVerticalAlignment(int) with one of the three
constants TOP , CENTER , or BOTTOM , as shown in Figure 12.19. The default vertical alignment
is AbstractButton.CENTER .
vertical alignment
Vertically top
Vertically center
Vertically bottom
F IGURE 12.19
You can specify how the icon and text are placed on a button vertically.
12.11.3 Text Positions
Horizontal text position specifies the horizontal position of the text relative to the icon. You
can set the horizontal text position using setHorizontalTextPosition(int) with one of
the five constants LEADING , LEFT , CENTER , RIGHT , or TRAILING , as shown in Figure 12.20.
At present, LEADING and LEFT are the same, and TRAILING and RIGHT are the same.
Future implementation may distinguish them. The default horizontal text position is
AbstractButton.RIGHT .
horizontal text position
Text positioned left
Text positioned center
Text positioned right
F IGURE 12.20
You can specify the horizontal position of the text relative to the icon.
Vertical text position specifies the vertical position of the text relative to the icon. You can
set the vertical text position using setVerticalTextPosition(int) with one of the three
vertical text position
 
 
Search WWH ::




Custom Search