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