| Java >
Guidelines Home Page > Java Look and Feel Design Guidelines >
Part III: The Components of the Java Foundation Classes > 10: Basic Controls >
A toggle button is a button that represents a setting with two states--on and off. Toggle buttons look similar to command buttons and display a graphic or text (or both) to identify the button. The graphic or button text should remain the same whether the button is in the on or off state. The state is indicated by highlighting the background of the buttons.
Toggle buttons can be placed in a button group to get radio button behavior.
An independent toggle button behaves like a checkbox. Whether it appears alone or with other buttons, its setting is independent of other controls. An example of an independent toggle button is a Bold button on a toolbar, as shown in the following illustration.Figure 154 Independent Toggle Buttons in a Toolbar
When users click the Bold button, it is highlighted to indicate that the bold style has been applied to the selection or that text to be entered will be bold. If the button is clicked again, it reverts to the normal button appearance and the bold style is removed from the selection.
Use toggle buttons (instead of checkboxes) in dialog boxes if you need consistency with a toolbar.
For recommendations on the spacing of toggle buttons, see Toggle Button Spacing.
A toggle button can work as part of a group to represent an exclusive choice within the set. A common example is a set of toolbar toggle buttons representing left, centered, and right text alignment, as shown in the following figure.Figure 155 Exclusive Toggle Buttons
If users click the button representing left alignment, the button is highlighted to indicate that text is aligned flush with the left border of the document. If users then click the button representing centered alignment, the appearance of the Align Left button reverts to the normal button appearance and the Center button is highlighted to indicate centered alignment of the selected text.
You can use grouped toggle buttons with labels equally well in toolbars or dialog boxes. In the example in Figure 156, the label identifies the abbreviations in the button text within a dialog box.
Click here to view the corresponding code for Figure 156 (also available on the book's companion CD-ROM).
For spacing guidelines for exclusive toggle buttons, see Checkbox and Radio Button Layout and Spacing.
|Java Look and Feel Design Guidelines, second edition.
Copyright 2001. Sun Microsystems, Inc. All Rights Reserved.