Disabled Jbutton Swing not working well

I have a problem with Swing JButtons. I work with Netbeans. When I disable JButton in the GUI Builder, it still triggers the actions attached as events, i.e. I have disabled the button with the onClick trigger. Regardless of whether it is disabled, the trigger works.

Does anyone know how to avoid this behavior? and disconnected jbutton only triggers actions when turned on?

Thank you so much

+3
source share
2 answers

You need to use ActionListener vs MouseClickListener.

Technically, the user clicked a button. :)

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

+4
source

Have you tried the button button.setEnabled (false) in the code? Maybe Netbeans is not setting the property correctly ...

+1
source

Source: https://habr.com/ru/post/1784152/


All Articles