# Greying out buttons in swing



## phreak0ut (Feb 16, 2009)

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 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)

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)

@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.


----------

