| ChangeListener | Text has changed |
| ClickListener | Something has been clicked |
| EventListener | A catch-all for when ANYthing happens |
| FocusListener | Something has got or lost focus |
| HistoryListener | The user/program has navigated history, or the program has added to the history |
| KeyboardListener | Keypress, or down or up |
| LoadListener | Something has loaded |
| MouseListener | The mouse has done something in your widget (yuk!) |
| MouseWheelListener | The mouse wheel has moved |
| PopupListener | A popup has popped up or down |
| ScrollListener | Scrolling has occurred |
| TableListener | A cell has been clicked |
| TreeListener | A tree item has been selected or its state has changed |
| WindowCloseListener | Window closing - Are you sure? Really sure? Positive? Please don't let me die! |
| WindowResizeListener | The window is a different size |
If you are in Eclipse, stick the cursor in a listener and press F3 (F3 will take you to where something is defined - very useful). You'll see that the listener is just an interface. And an interface is just an agreement for how things fit together.
Your side of the agreement is to provide the methods (even if they are empty and don't do anything) that are mentioned in the interface. Google has written the code for the other side of the agreement in the widget it supplies.
Once you have made something that complies, then you can register that thing
with the Google widget - addClickListener(myListener) maybe -
and when an event happens (a click, for example), the widget will run your
code for you - and your code does something in the program you are writing.
The 'sender' in, say, public void onClick(Widget sender) refers
to the widget which is sending the event. So if the user clicks a button, the
sender is the button they clicked. This means, of course, that you can identify
where the click came from and can recreate it with, for example
Button button = (Button)sender;
If you go a step further, you could subclass the Button class and add in your own fields. The menu items on this site do that for a label, and the subclassed label has a field which holds the page widget to be displayed, i.e. what you are reading now.