The JToggleButton.ToggleButtonModel Class
As we mentioned earlier, JToggleButton does not use the DefaultButtonModel class as its model.
ToggleButtonModel, a public static
inner class that extends DefaultButtonModel, is used instead.
Properties
ToggleButtonModel modifies
the methods for working with the properties listed in Table 5-11. New
implementations of isSelected( )
and setSelected( )
use the button’s ButtonGroup (if
defined) to keep track of which button is selected, ensuring that even
if multiple selected buttons are added to a group, only the first one
is considered selected (since the group keeps track of the
“officially” selected button). In addition, the setPressed( ) method is redefined to call
setSelected( ) when the button is
released (if it is armed)
Table 5-11. JToggleButton.ToggleButtonModel properties
Property | Data type | get | is | set | Default value |
|---|---|---|---|---|---|
pressedo | boolean | · | · | | |
selectedo | boolean | · | · | | |
ooverridden See also properties from |
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