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 に答える