JButtons re-enable themselves after being disabled
Posted
by Anarchist
on Stack Overflow
See other posts from Stack Overflow
or by Anarchist
Published on 2010-04-14T19:26:53Z
Indexed on
2010/04/15
16:23 UTC
Read the original article
Hit count: 271
I have an array of JButtons which form a keypad interface. After six numbers are entered I want to disable the keypad so that no further numbers can be entered by the user.
I have written the code and the buttons do disable until the mouse hovers above any of them, then the buttons seem to re-enable themselves and run actionEvents added to them.
The full code is available here.
Possible things that I think are wrong.
- There is some sort of MouseListener which is ignoring when I set
button.setEnabled(false); - I haven't separated attributes from the
buildGUI();correctly, I only did this anyway so that the inner class could access them. - Possibly something to do with the
gridLayoutas disabling the buttons seems to work for myservicesJPanel buttons.
© Stack Overflow or respective owner