The JRadioButton Class
JRadioButton is a subclass of JToggleButton, typically used with other
JRadioButtons, that allows users to
make a single selection from a set of options (Figure 5-8). Because radio buttons
form a set of choices, JRadioButtons
are usually used in groups, managed by a ButtonGroup (described in the next section).
If you specify an icon for the radio button, you should also specify a
selected icon so it will be visually apparent if a button is
selected.

Figure 5-8. JRadioButtons in four L&Fs
Properties
The JRadioButton class
inherits all its properties and most of its default values from its
superclass. The only exceptions are shown in Table 5-14. By default, no
border is painted on JRadioButtons, and their horizontalAlignment is set to the leading
edge (to the left in the default locale, in which text reads left to
right).[7]
Table 5-14. JRadioButton properties
Property | Data type | get | is | set | Default value |
|---|---|---|---|---|---|
accessibleContexto | AccessibleContext | · | JRadioButton.AccessibleJRadioButton( ) | ||
borderPaintedo | boolean | · | · | false | |
horizontalAlignmento | int | · | · | LEADING1.4 | |
UIClassIDo | String | · | “RadioButtonUI” | ||
1.4since 1.4, ooverridden See also
properties from |
Events
See the discussion of JToggleButton (JRadioButton’s superclass) events.
Constructors
- public JRadioButton( )
Create a button that has no text or icon and is not selected.
- public JRadioButton(Action a)
Create a ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access