How to set SWT button foreground color?

前端 未结 4 1807
后悔当初
后悔当初 2020-12-02 02:03

The SWT Button class has a setForeground(Color) method but it seems to have no effect (the method is actually on Button\'s superclass). The javadoc says that th

4条回答
  •  伪装坚强ぢ
    2020-12-02 02:47

    On Windows, setForeground for Buttons has no effects.

    As a workaround, add a PaintListener to your Button. On this Listener's paintControl method, get the generated event's GC and, with it, re-write the text of your Button using the color you want.

    You can, in fact, draw anything over your Button.

提交回复
热议问题