I'm using Flamingo/Substance in开发者_如何学运维 a Swing application and can't figure out a simple way to affect the text color for a JCommandButton
. Explicitly setting the foreground color seems to have no effect:
JCommandButton button = new JCommandButton("Button");
button.setForeground(Color.red);
Do I have to extend JCommandButton
to do this? If so, how do I override this behavior? Thanks.
I'm not sure if this is the preferred way of doing it, but I ended up extending the delegate to get the result I wanted:
class CustomCommandButtonUI extends BasicCommandButtonUI {
@Override
protected Color getForegroundColor(boolean isTextPaintedEnabled) {
return Color.red;
}
}
精彩评论