Background color only for SWT Combo Read Only mode
I want a read-only dropdown to appear in my Eclipse RCP application, but when I set the read-only flag, the background is always grayed out. This is my code:
Combo combo = new Combo(fCompositeLogin_1, SWT.READ_ONLY);
combo.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
combo.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 2, 1));
for(String i : items) {
combo.add(i);
}
combo.select(0);
I would like to have it on a white background, how can I do that?
thank
+3
source to share
1 answer
This is possible by wrapping the Combo inside a white composite and setting it to composite inheritance.
Composite composite = new Composite(parent, SWT.NONE);
composite.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
composite.setBackgroundMode(SWT.INHERIT_FORCE);
comboCombo = new Combo(composite, SWT.READ_ONLY);
+1
source to share