Java Reference
In-Depth Information
The borderPaintedFlat property permits a look and feel to display the border around
the check icon as two-dimensional (flat) instead of three-dimensional. By default, the
borderPaintedFlat property is false , meaning the border will be three-dimensional. Figure 5-6
shows what a flat border looks like, where the first, third, and fifth borders are flat, and the
second and fourth are not. A look and feel may choose to ignore this property. However, it is
useful for renderers for components such tables and trees, where they show only state and are
not selectable. The Windows and Motif look and feel types take advantage of the property;
Metal (and Ocean) does not.
Figure 5-6. Alternating flat JCheckBox borders for the Windows look and feel: Anchovies, Onions,
and Spinach are flat; Garlic and Pepperoni are not.
As the constructor listing demonstrated, if you choose to set an icon with a constructor,
the constructor sets only one icon for the unselected state. If you want the check box icon to
show the correct state visually, you must use a state-aware icon or associate a different icon for
the selected state with setSelectedIcon() . Having two different visual state representations is
what most users expect from a JCheckBox , so unless you have a good reason to do otherwise, it's
best to follow the design convention for normal user interfaces.
The fourth button at the bottom of the screen shown in Figure 5-7 demonstrates confusing
icon usage within a JCheckBox . The check box always appears selected. The figure displays what
the screen looks like with Pizza selected, Calzone unselected, Anchovies unselected, and Stuffed
Crust unselected (although the last one appears selected).
Figure 5-7. Multiple JCheckBox components with various icons
 
Search WWH ::




Custom Search