【发布时间】:2017-08-23 14:17:04
【问题描述】:
我正在做一个带有表单多页编辑器的 Eclipse 插件。
在其中一个页面上,我将页面分成两半,并在两个不同的类中生成页面。在 FormPage 中,我添加了这两部分,一切都很好。
现在我的问题:在每一侧,我都有一个设置为 READ_ONLY 的组合框。问题是第二个 Combo 的项目依赖于第一个 Combo 中的选定项目。
我的代码的小模型:
//something
new FirstHalf(Stuff);
new SecondHalf(OtherStuff);
----------
public int firstComboIndex = 0;
public FirstHalf(Stuff){
Combo firstCombo = new Combo(SomeClient, SWT.READ_ONLY);
String[] itemsArray = new String[stuff];
firstCombo.setItems(itemsArray);
firstCombo.setText(itemsArray[firstComboIndex]);
}
----------
public int secondComboIndex = 0;
public SecondHalf(Stuff){
Combo secondCombo = new Combo(SomeOtherClient, SWT.READ_ONLY);
String[] array1 = new String[stuff];
String[] array2 = new String[stuff];
String[] array3 = new String[stuff];
String[][] arrays = { array1, array2, array3};
String[] secondItemsArray = new String[arrays[firstComboIndex];
secondCombo.setItems(secondItemsArray);
secondCombo.setText(secondItemsArray[secondComboIndex]);
}
现在我该怎么做,当第一个组合选择改变时。第二个也发生了变化。
【问题讨论】:
-
试试
SelectionListener...