Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SWT Combo Read Only mode background color

Tags:

java

swt

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

like image 289
breakline Avatar asked Jan 01 '26 09:01

breakline


1 Answers

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);
like image 131
user3649850 Avatar answered Jan 02 '26 22:01

user3649850



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!