开发者

Override default foreground color for Flamingo's JCommandButton

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;
  }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜