Dynamic list with list in java swt table

I am creating a combo-box control in the org.eclipse.swt.widgets.Table file Snippet 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 list of lists for a selected row in a table (for example, item1, item2, etc., changed to item4, item5, item7, etc. only for row 5) by triggering an event. An event in my case is a choice in another combined field, the list of which does not change

+3
source share
2 answers

You must install the SelectionListener on another CCombo in order to trigger the update on your second CCombo.

WavAudioSettingComposite .

- :

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]);
    }
}
+2

TableEditor docs , .

Combo .

0

Source: https://habr.com/ru/post/1704436/


All Articles