How to find in Java if JToggleButton is pressed
How to find in Java if JToggleButton is pressed 开发者_如何学Cand if it is pressed to set to be unpressed ?
All such things you can get from ButtonModel.
getModel().isPressed()
Have you try the isSelected()
method ?
or inside public void actionPerformed(ActionEvent event) {...}
is possible to check
AbstractButton abstractButton = (AbstractButton) event.getSource();
boolean selected = abstractButton.getModel().isSelected();
精彩评论