Re: How to grey-out jButton with HTML in label
- From: "Filip Larsen" <filip.larsen@xxxxxxxxx>
- Date: Thu, 30 Jun 2005 10:08:24 +0200
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
.
- References:
- How to grey-out jButton with HTML in label
- From: michael . o'connor
- How to grey-out jButton with HTML in label
- Prev by Date: Re: Truncated Label Problem
- Next by Date: Re: Problem using JEditor in swing
- Previous by thread: How to grey-out jButton with HTML in label
- Next by thread: JPanel in JTable cell
- Index(es):