开发者

Disabled Jbutton Swing not working well

开发者 https://www.devze.com 2023-02-02 21:44 出处:网络
I have a problem with开发者_运维知识库 Swing JButtons. I\'m working with Netbeans. When I disable a JButton in the GUI Builder it still fires the actions attached as events, i.e. I have a disabled but

I have a problem with开发者_运维知识库 Swing JButtons. I'm working with Netbeans. When I disable a JButton in the GUI Builder it still fires the actions attached as events, i.e. I have a disabled button with an onClick trigger. No matter if disable, the trigger is working.

Somebody knows how to avoid this behavior? and the disabled jbutton fires the actions just when enabled?

Thanks a lot


You need to use an ActionListener vs a MouseClickListener.

Technically, the user did click in your button. :)

http://download.oracle.com/javase/tutorial/uiswing/events/actionlistener.html


Did you try a button.setEnabled(false) in code ? Maybe Netbeans is not setting the property properly...

0

精彩评论

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