Skip to content

Instantly share code, notes, and snippets.

@suxiaogang
Last active December 18, 2015 00:19
Show Gist options
  • Save suxiaogang/5695833 to your computer and use it in GitHub Desktop.
Save suxiaogang/5695833 to your computer and use it in GitHub Desktop.
Disable a control in SWT
public void switchDisableOfControl(Control control,boolean flag){
if (control instanceof Composite) {
Composite comp = (Composite) control;
for (Control c : comp.getChildren())
switchDisableOfControl(c, flag);
} else {
control.setEnabled(flag);
//text
if(control instanceof Text){
((Text) control).setText("");
((Text) control).setBackground(flag ? null : Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));//
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment