开发者

Override default foreground color for Flamingo's JCommandButton

开发者 https://www.devze.com 2023-03-25 01:29 出处:网络
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

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

精彩评论

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