I'd like to have a read-only combo dropdown in my Eclipse RCP application but when I set the Read Only flag the background always stays gray. 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'd like to have it with a white background, how can I do this?
Thank you
This is possible by wrapping the Combo inside a white composite and setting the composite's inherit mode to force.
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With