Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamic combo-box list in java swt table

I create a combo-box control in org.eclipse.swt.widgets.Table The code snippet is below

...
TableEditor editor = new TableEditor (table_LLSimDataFileInfo);
CCombo combo = new CCombo (table_LLSimDataFileInfo, SWT.NONE);
combo.setText("CCombo");
combo.add("item 1");
combo.add("item 2");
editor.grabHorizontal = true;
editor.setEditor(combo, items[i], 0);
...

How can I dynamically change the combo-box list for a selected row in the table (For e.g. item1, item2 etc changed to item4, item5, item7 etc for row 5 only) by triggering of some event. The event in my case is selection in another combo-box whose list does not change

like image 355
amarnath vishwakarma Avatar asked Dec 05 '25 17:12

amarnath vishwakarma


1 Answers

You should set a SelectionListener on your other CCombo, in order to call an update on your second CCombo.

This WavAudioSettingComposite class is a good example.

Something like:

public class ValueChanged extends SelectionAdapter {

    public void widgetSelected(SelectionEvent e) {
        if(e.getSource()==myFirstCCombo){
            // call update on your second CCombo
        }
    }
}

public void updateSecondCCombo(int[] newValues){
    int oldbitrate=getFramerate();
    mySecondCCombo.removeAll();

    for (int i = 0; i < newValues.length; i++) {
        mySecondCCombo.add(""+newValues[i]);
    }
}
like image 144
VonC Avatar answered Dec 08 '25 06:12

VonC



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!