Hi, powerful programmers, once again as a n00b newbie, I ask you for help ...
The problem is this: I have a child window containing several labels, buttons and two drop-down menus. I want to have a SelectionListener in the same combo box named 'name' so that the selected value from this drop-down list affects the selected value in the second Combo-desc.
How to do it?
if i uncomment
at
name.addSelectionListener(new SelectionAdapter())
eclipse wants me to change Combo desc and the name Combo to final, which is impossible, because this will require initializing them outside the loop that ruined my layout :(
Here is the code:
public void tariffAddWindow(final Shell childWindow) {
childWindow.setText("add dialog");
labels = new Label[operatorTariffData.getColumnNames().length];
inputTexts = new Text[operatorTariffData.getColumnNames().length];
final Button buttons[] = new Button[operatorTariffData.getColumnNames().length];
Combo name = null;
Combo desc = null;
for (int i =1; i< operatorTariffData.getColumnNames().length; i++) {
labels[i] = new Label(childWindow, SWT.NONE);
labels[i].setText(operatorTariffData.getColumnNames()[i].toString());
labels[i].setBackground(blue);
if (i == 3) {
name = new Combo(childWindow, SWT.READ_ONLY | SWT.BORDER);
name.setLayoutData(tLayout);
buttons[i] = new Button(childWindow, SWT.PUSH);
buttons[i].setText("e");
} else if (i == 4) {
desc = new Combo(childWindow, SWT.READ_ONLY | SWT.BORDER);
desc.setLayoutData(tLayout);
buttons[i] = new Button(childWindow, SWT.PUSH);
buttons[i].setText("e");
} else {
inputTexts[i] = new Text(childWindow, SWT.None);
inputTexts[i].setLayoutData(tLayout);
buttons[i] = new Button(childWindow, SWT.TOGGLE);
buttons[i].setText("x");
buttons[i].setSelection(false);
}
}
for (int i = 1; i < contentProvider.getTariffNames().getQueryRowCount(); i++) {
name.add(contentProvider.getTariffNames().getQueryData()[i][3].toString());
desc.add(contentProvider.getTariffNames().getQueryData()[i][2].toString());
}
name.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
}
});
}
source
share