More Events

------------------------------------------
As you saw in the last lesson you can handle events in a variety of ways. In fact we could make a four by two matrix representing our options:

Adapter ClassesListener Interfaces
Outer Classesthis lessonthis lesson
Classesnext lessonnext lesson
Inner Classestwo lessons from nowtwo lessons from now
Low-Levelthree lessons from nowthree lessons from now

For further information study these pages:

Java Event Model
Examples of six different approaches (EXCELLENT EXAMPLES!)
Examples Using Inner Classes
Example Using Low Level Event Handling

------------------------------------------
Java 1.1 Event Types, Listeners, and Listener Methods:

Event ClassListener InterfaceListener Methods
ActionEventActionListeneractionPerformed()
AdjustmentEventAdjustmentListeneradjustmentValueChanged()
ComponentEventComponentListener componentHidden()
componentMoved()
componentResized()
componentShown()
ContainerEventContainerListener componentAdded()
componentRemoved()
FocusEventFocusListener focusGained()
focusLost()
ItemEventItemListeneritemStateChanged()
KeyEventKeyListenerkeyPressed()
keyReleased()
keyTyped()
MouseEventMouseListener mouseClicked()
mouseEntered()
mouseExited()
mousePressed()
mouseReleased()
MouseMotionListener mouseDragged()
mouseMoved()
TextEventTextListenertextValueChanged()
WindowEventWindowListener windowActivated()
windowClosed()
windowClosing()
windowDeactivated()
windowDeiconified()
windowIconified()
windowOpened()

Any Listener interface which provides more than one method has a corresponding Adapter class. When you implement an interface you must provide definitions for all of its methods. When you extend a class you only provide definitions for the methods you wish to override. This is the advantage of using Adapter classes: You only have to provide definitions for the methods you wish to use.
------------------------------------------
Example One: External Class, Listener Interface, List Component:

Notice the constructor for the IL class. It takes an instance of the list class as an argument. This is so items from the list class can be accessed within the IL class. This would not be necessary if we had used inner classes.
------------------------------------------
Example Two: External Class, Adapter Class, Scrollbar Component:


------------------------------------------
Thinking In Java: Read the following sections from chapter thirteen: "Check Boxes and Radio Buttons," "Drop-down Lists," "Lists," and "Menus."

------------------------------------------
Assignment: Recreate the following applet:

You will need to use panels to recreate the exact layout... but you don't have to be perfect, but it will still have to be pretty darn good.