Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabled Jbutton Swing not working well

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

like image 312
Ron Avatar asked Feb 27 '26 10:02

Ron


2 Answers

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

like image 56
bb121622 Avatar answered Feb 28 '26 22:02

bb121622


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

like image 41
Twister Avatar answered Mar 01 '26 00:03

Twister



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!