当我在组合框上使用setEnabled()(并将其设置为false)时,我想知道如何更改文本颜色,使其为黑色而不是灰色。我正在为自己开发软件的人和我自己发现,阅读起来太难,我无法找到访问文本颜色的方式。这很容易修复文本组件,因为我只需要使用setEditable(),而不是灰色的文本颜色,但没有setEditable()方法可用于SWT中的组合框。Java SWT当组合框setEnabled()为false时更改文本颜色
为了进一步澄清,我试图覆盖的方法,但它不会用我的方法,而是使用下面的继承的方法...
public void setEnabled (boolean enabled) {
checkWidget();
/*
* Feature in Windows. If the receiver has focus, disabling
* the receiver causes no window to have focus. The fix is
* to assign focus to the first ancestor window that takes
* focus. If no window will take focus, set focus to the
* desktop.
*/
Control control = null;
boolean fixFocus = false;
if (!enabled) {
if (display.focusEvent != SWT.FocusOut) {
control = display.getFocusControl();
fixFocus = isFocusAncestor (control);
}
}
enableWidget (enabled);
if (fixFocus) fixFocus (control);
}
我找不到文字画代码在这里,现在我变得更加困惑,因为我更熟悉Swing,它具有UIManager ,在这种情况下,它将看起来像UIManager.put(“ComboBox.disabledText”,Color.black);我不确定是否有相当于SWT ...任何帮助,非常感谢!