我的目的是根据通过下拉框设置的条件来更改复选框的值。我被困在这个地方了。但这并没有按预期工作。
public void notifyChanged(IPropertyEditor otherEditor) {
ConnectionType changedConnectionType = getConnectionType(otherEditor);
if (!ConnectionType.UNDEFINED.equals(changedConnectionType)) {
connectionType = changedConnectionType;
updateChange(false);
}
if (button != null && !ConnectionType.UNDEFINED.equals(connectionType)) {
button.setEnabled(canEnable(connectionType));
updateChange(true);
}
}
private void updateChange(boolean selected){
this.selected=selected;
setChanged();
notifyObservers();
}
最佳答案
调用 Button
的 setSelected(boolean)
方法来选中复选框。
setEnabled
调用将控件标记为启用或禁用(不可用)。
关于java - SWT:以编程方式更改复选框值时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44862362/