I l@ve RuBoard Previous Section Next Section

5.6 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.

5.6.1 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

 

·

·

false

selectedo

boolean

 

·

·

false

ooverridden

See also properties from DefaultButtonModel (Table 5-3).

    I l@ve RuBoard Previous Section Next Section