0
我正在做一个Form MultiPage Editor的Eclipse插件。SWT Eclipse组合事件
在其中一个页面上,我将页面分成两部分,并生成两个不同类的页面。在FormPage中添加这两个一半,一切都很好。
现在我的问题:在每一边我有一个组合框设置为READ_ONLY。问题在于第二个组合的项目依赖于来自第一个组合的选定项目。
我的代码的小样机:
//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' ... –