I l@ve RuBoard |
![]() ![]() |
5.2 The DefaultButtonModel ClassSwing provides an implementation of the ButtonModel interface called DefaultButtonModel. This class is used directly by the AbstractButton class and indirectly by the other button classes. JToggleButton defines an inner class extending DefaultButtonModel that it and its descendants use to manage their state data. 5.2.1 PropertiesThe DefaultButtonModel class gets most of its properties from ButtonModel. The default values set by this class are shown in Table 5-3.
The only property here that does not come from the ButtonModel interface is the selectedObjects property. DefaultButtonModel provides a getSelectedObjects( ) method because it is mandated by the ItemSelectable interface, but it always returns null. SDK 1.3 added the getGroup( ) method. 5.2.2 EventsThe events fired by DefaultButtonModel are those required by ButtonModel and listed in Table 5-2. An ActionEvent is fired when the button is pressed, an ItemEvent is fired when the button's state is changed, and a ChangeEvent is fired when a change has occurred to the button's properties. This class implements the following standard methods:
Note that the ButtonModel properties are not technically "bound properties" as defined by the JavaBeans specification because the lighter-weight ChangeEvent is sent when they change, rather than the standard PropertyChangeEvent. 5.2.3 ConstantsDefaultButtonModel uses the constants shown in Table 5-4 to store internal state.
5.2.4 Constructor
![]() |
I l@ve RuBoard |
![]() ![]() |