Re: How to grey-out jButton with HTML in label



Mike wrote

> I have a jButton with HTML embedded in the label text, and when the
> jButton is disabled, the label is not greyed-out in the usual way. How
> do I get around this?

To my knowledge, the enabled state is not carried over to the ultimate
component responsible to render the html text (see the source code for
javax.swing.plaf.basic.BasicButtonUI and
javax.swing.plaf.basic.BasicHTML for details here).

You can simulate the effect of disabling by setting the foreground color
just like the BasicButtonUI do on non-HTML text:

jButton1.setEnabled(false);
jButton1.setForeground(jButton1.getBackground().darker());

and set it back to its previous color when you re-enable the button. If
you have many buttons like this you can write a small class that listens
on the button and do it all for you.


Regards,
--
Filip Larsen


.