2

我在 Swing 应用程序中使用 Flamingo/Substance,无法找到一种简单的方法来影响JCommandButton. 显式设置前景色似乎没有效果:

JCommandButton button = new JCommandButton("Button");
button.setForeground(Color.red);

我必须扩展JCommandButton才能做到这一点吗?如果是这样,我该如何覆盖这种行为?谢谢。

4

1 回答 1

3

我不确定这是否是首选的方法,但我最终扩展了委托以获得我想要的结果:

class CustomCommandButtonUI extends BasicCommandButtonUI {
  @Override
  protected Color getForegroundColor(boolean isTextPaintedEnabled) {
    return Color.red;
  }
}
于 2011-08-03T15:31:51.593 回答