java swt表中的动态组合框列表

时间:2009-03-09 13:03:34

标签: java eclipse combobox swt

我在org.eclipse.swt.widgets.Table中创建了一个组合框控件 代码段位于

之下
...
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);
...

如何通过触发某个事件动态更改表中所选行的组合框列表(例如,item1,item2等仅更改为第4行的item4,item5,item7等)。在我的情况下,事件是在另一个组合框中选择,其列表不会改变

2 个答案:

答案 0 :(得分:2)

您应该在其他CCombo上设置 SelectionListener ,以便在第二个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]);
    }
}

答案 1 :(得分:0)

TableEditor文档显示了一个简单示例,其中包含一个标识当前所选行的选择侦听器。

您只需自定义此示例,动态填写所选行的Combo