Thank you very much, thomas here's the final sample code and it really works... :)
but the problem is, in the MainMenu, I don't know which listbox that send the listener. in the MainMenu, I provide three textboxes txtListA = catch the event from listA txtListB = catch the event from listB txtListC = catch the event from listC so, I have to know first, the name of the sender widget, (which is listA? listB? or listC?) then set the txtListA.setText(listA); and so on I have no idea, how to get the sender name. I have tried sender.getclass().getname() but the result is not what I want. please help me (again) ;) best regards /**************** * iCombo.java ****************/ public class iCombo extends Composite implements SourcesChangeEvents { private HorizontalPanel hPanel = new HorizontalPanel(); private ListBox ListA = new ListBox(); private ListBox ListB = new ListBox(); private ListBox ListC = new ListBox(); private ChangeListenerCollection listeners = new ChangeListenerCollection(); public iCombo () { hPanel.add(ListA); hPanel.add(ListB); hPanel.add(ListC); FillList(); ListA.addChangeListener(new ChangeListener() { public void onChange(Widget arg0) { listeners.fireChange(ListA); } }); ListB.addChangeListener(new ChangeListener() { public void onChange(Widget arg0) { listeners.fireChange(ListB); } }); ListC.addChangeListener(new ChangeListener() { public void onChange(Widget arg0) { listeners.fireChange(ListC); } }); initWidget(hPanel); } private void FillList() { ListA.clear(); ListA.addItem("ListA1"); ListA.addItem("ListA2"); ListA.addItem("ListA3"); ListB.clear(); ListB.addItem("ListB1"); ListB.addItem("ListB2"); ListB.addItem("ListB3"); ListC.clear(); ListC.addItem("ListC1"); ListC.addItem("ListC2"); ListC.addItem("ListC3"); } public void addChangeListener(ChangeListener listener) { listeners.add(listener); } public void removeChangeListener(ChangeListener listener) { listeners.remove(listener); } } /**************** * iComboParent.java ****************/ public class iComboParent extends Composite implements SourcesChangeEvents { private HorizontalPanel vPanel = new HorizontalPanel(); private iCombo MyCombo = new iCombo(); private Button btn1 = new Button("OK"); private ChangeListenerCollection listeners = new ChangeListenerCollection(); public iComboParent() { vPanel.add(MyCombo); vPanel.add(btn1); initWidget(vPanel); MyCombo.addChangeListener(new ChangeListener() { public void onChange(Widget sender) { listeners.fireChange(sender); } }); } public void addChangeListener(ChangeListener listener) { listeners.add(listener); } public void removeChangeListener(ChangeListener listener) { listeners.remove(listener); } } /**************** * MainMenu.java ****************/ public class MainMenu implements EntryPoint { private VerticalPanel vPanel = new VerticalPanel(); private TextBox txtListA = new TextBox(); private TextBox txtListB = new TextBox(); private TextBox txtListC = new TextBox(); private ComboParent cp = new ComboParent (); public void onModuleLoad() { vPanel.add(txtListA); vPanel.add(txtListB); vPanel.add(txtListC); vPanel.add(cp); cp.addChangeListener(new ChangeListener() { public void onChange(Widget sender) { ListBox lb = (ListBox) sender; txtListA.setText(lb.getItemText(lb.getSelectedIndex())); } }); RootPanel.get().add(vPanel); } } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to Google-Web-Toolkit@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~----------~----~----~----~------~----~------~--~---