JButton question

Can you disable the JButton without seeding the button itself? When you use setEnbaled (false), the button is disabled and grayed out. Is it possible to disable a button but make the button look the same?

+1


a source to share


2 answers


You can ignore button clicks in the ActionListener if the flag is set; however, you shouldn't disable a button without showing it as disabled: it only confuses the users of your application.



+3


a source


I suggest installing ButtonModel

with setArmed

and overrides setPressed

. Exactly how you override this depends on what you want it to do - for example if it is clicked, clicked, for example? Install ButtonModel

only once at a time JButton

. Add or reset the state to ButtonModel

to indicate how you want it to behave at any time.



Obviously, graphical interfaces with non-standard behavior can be confusing for users.

+1


a source







All Articles