How to change the look of a disabled JButton in java

Patrick picture Patrick · Oct 19, 2009 · Viewed 18.2k times · Source

I am making a game and when I disable a button with setEnabled(false); the buttons turns grey which clashes with the other colors in the game. Is their a way to change the color of the button when it is disabled?

Answer

user929404 picture user929404 · Sep 5, 2011

You can add HTML coding to your button which gives a large range of flexibility, even to disabled buttons.

Example: button.setText("<html><font color = red>3</font></html>");