2011-08-01 55 views
2

我在Swing應用程序中使用Flamingo/Substance,並且無法找出影響JCommandButton的文本顏色的簡單方法。明確設置前景色似乎沒有任何效果:覆蓋火烈鳥的JCommandButton的默認前景色

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

我必須延長JCommandButton做到這一點?如果是這樣,我該如何覆蓋這種行爲?謝謝。

回答

3

我不知道這是否是這樣做的首選方式,但我結束了延長委託來獲得我想要的結果:

class CustomCommandButtonUI extends BasicCommandButtonUI { 
    @Override 
    protected Color getForegroundColor(boolean isTextPaintedEnabled) { 
    return Color.red; 
    } 
} 
+1

對不起,一直在休假和工作期限和這樣。是的,目前這是您必須重寫命令按鈕的文本顏色的方式。這聽起來像是一個很好的RFE:https://github.com/insubstantial/insubstantial/issues – shemnon