Combo selection by programm and addSelectionListener [message #457697] |
Sat, 02 July 2005 17:20 |
Eclipse User |
|
|
|
Originally posted by: prokopiev.stc.donpac.ru
Hi,
I have the code:
combo.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
// do something
}
});
if (combo.getItemCount() > 0)
combo.select(0);
If I select any item by hand in running programm, method widgetSelected
is executed. But combo.select(0) is not call widgetSelected.
What's wrong?
--
Thanks,
Eugene Prokopiev
|
|
|
|
Re: Combo selection by programm and addSelectionListener [message #457824 is a reply to message #457716] |
Tue, 05 July 2005 05:12 |
Eclipse User |
|
|
|
Originally posted by: prokopiev.stc.donpac.ru
> you should use <<if (combo.getItemCount() > 0)
> combo.select(0);>> WITHIN <<public void widgetSelected(SelectionEvent
> e)>> (a.k.a. WITHIN your SelectionAdapter),
> otherwise it wont't work during runtime, only the one time you are
> creating your enclosing class.
I don't need combo.select(0) in SelectionAdapter, I need to do it in
some other places. Is there no way to select item by program and execute
widgetSelected?
Now I use:
jdbcConnections.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
setupConnection(jdbcConnections.getSelectionIndex());
}
));
if (jdbcConnections.getItemCount() > 0) {
jdbcConnections.select(0);
setupConnection(0);
}
But it's ugly code.
--
Thanks,
Eugene Prokopiev
|
|
|
|
Powered by
FUDForum. Page generated in 0.04021 seconds