JButton creation remains suppressed manually

I would like JButton to remain pressed and not be able to be pressed again until some event occurs, is there an easy way to do this?

+2
source share
3 answers

Perhaps you just want to disable the button? Try setEnabled(false) in your button callback.

+4
source

You should probably take a look at the JToggleButton class. Associate it with an action that calls setEnabled (false) to disable interaction.

After your event, you call setEnabled (true) and setSelected (false) to restore the button to its original state.

+7
source

I think you should take a look at the JButton Swing class here . This allows you to have a status button 2, and therefore why you just need to attach your button to some logical value, letting it choose or not.

+2
source

All Articles