在Windows中更改org.eclipse.swt.widgets背景颜色

在Windows中更改org.eclipse.swt.widgets背景颜色

问题描述:

现在我试图使用以下代码更改org.eclipse.swt.widgets.Button的背景颜色:

Right now I am trying to change the background color of a org.eclipse.swt.widgets.Button with the following code:


    Button sceneButton = new Button(border, SWT.TOGGLE | SWT.FLAT);  
    sceneButton.setBackground(Color.RED);

这在我在Solaris中运行程序时正常工作,但在Windows中运行代码时什么也不做。这可能吗?如果没有,是否有某种解决方法,将允许我改变背景颜色(即使颜色是一个图像),同时仍然显示在按钮中的文本?谢谢!

This works fine when I run the program in Solaris, but does nothing when I run the code in Windows. Is this possible? If not, is there some kind of workaround that would allow me to change the background color (even if the "color" is an image) while still displaying text in the button? Thanks!

你不能。在方法文档 Control.setBackground() ,提到:

You can't. In the documentation of method Control.setBackground(), it is mentioned:

的按钮不能更改。