Reputation: 123
I know that subscribing for ItemListener
on the checkbox one can get the ItemEvent.SELECTED/DESELECTED
state inside the method:
public void itemStateChanged(ItemEvent e) {
if(e.getStateChange()==ItemEvent.DESELECTED){
}
....
}
But what I want to know is the "last selection state" that the JComboBox during the state-change is actually happening. As JCheckBox
extends JToggleButton
, there must me some way to know that as the java buttons do have an intermediate state-value like "pressed" before it actuallly changed to the new state. But I coudn't find out the way to have it in case of JCheckBox
Upvotes: 0
Views: 159
Reputation: 123
what about if I cast the event source to AbstractButton and then do as following:
ChangeListener changeListener = new ChangeListener() {
public void stateChanged(ChangeEvent changeEvent) {
AbstractButton abstractButton = (AbstractButton)
changeEvent.getSource();
ButtonModel buttonModel = abstractButton.getModel();
boolean armed = buttonModel.isArmed();
boolean pressed = buttonModel.isPressed();
boolean selected = buttonModel.isSelected();
.......
}
};
Upvotes: 0