Last active
December 18, 2015 00:19
-
-
Save suxiaogang/5695833 to your computer and use it in GitHub Desktop.
Disable a control in SWT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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