DIGIT-ARC read-only archive · snapshot: July 23, 2026

Greying out buttons in swing

4 posts · originally from https://geek.digit.in/community/threads/greying-out-buttons-in-swing.108794/

phreak0ut
phreak0ut Original post #1
Feb 16, 2009 at 8:35 PM
How to grey out buttons after it is clicked in Swing? Like, when we click Apply, it's greyed out in most applications.
QwertyManiac
Feb 16, 2009 at 9:25 PM
At the end of the operation performed, call buttonObject.setEnabled(false);

The question seems too trivial to ask, maybe you're looking for an automatic solution? In case of that, I do not know and I hope someone with proper Swing experience would come along and answer that.

P.s. Is there, by any chance or anything similar to, a formObject.isDirty() call? You could use that in a validator function that keeps listening.
phreak0ut
Feb 16, 2009 at 9:36 PM
I'm still pretty new to Swing and don't have much idea as to what are the methods available. I'll try the one you suggested QM. It's like clicking on Apply after you chose your screensaver in Windows and the button greys out.
phreak0ut
Mar 1, 2009 at 11:17 AM
@QM your suggestion worked. Now, it's time to apply action listener to enable once the text boxes are filled and another button is clicked.