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



Java Swing
Graphic Java 2: Mastering the Jfc, By Geary, 3Rd Edition, Volume 2: Swing
ISBN: 0130796670
EAN: 2147483647
Year: 2001
Pages: 289
Authors: David Geary

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net