开发者

How to find in Java if JToggleButton is pressed

开发者 https://www.devze.com 2023-02-27 00:52 出处:网络
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.

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();
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号