The Java Application Programmers Interface 1.2
The Java 1.2 API was once indexed and documented by Sun.
Notes
Child::@Parent...indicates that Child implments or extends the Parent class.
Event Handling
Many components(objects in class Component) implement a function like this:
component.addTypeListener(l) where l is in a class that implements the
TypeListener interface and Type is a name of a type of AWTEvent.
The TypeListener interface defines a
a void function actionsomething(TypeListener event). The
something varies with the Type of the event. Another class can define
a class that implements TypeListener by handling the events. It
constructs an object of this tpe and passes it to the component
using the addTypeListener function. When events occur the
implemented function is called with arguments defining the event.
anXListener---implements--->interface----used by---->aComponent
anXListener-passed by-addXListener(anXListener)-to-->aComponent
anXListener<------gets called when an XEvent hits----aComponentA more detailed model using the Unified Modeling Language can be downloaded: [ listener.mdl ] and viewed with Rational Rose.
To support this model Java1.2 makes it easier to construct and object and and describe its class in a single statement [ html#anonymous_class_object ] -- without having to name the class.
The event handling uses grouped classes of AWTEvents, addListener functions, Listener interfaces, and Adapter classes. To implement one of the interfaces below the class must (1) state that it "implements Interface_name" in its header and (2) define all the functions listed in the interface. The Adapter classes supply default empty functions for the functions in the interface, so by extending an Adapter class you only have to defined the listening functions that do something.
Event | Sent by | To | Added by | Adapter |
---|---|---|---|---|
ActionEvent | Button,List,MenuItem,TextField | ActionListener:actionPerformed | addActionListener | ActionAdapter |
AdjustmentEvent | Scrollbar | AdjustmentListener:adjustmentValueChanged | addAdjustmentListener | AdjustmentAdapter |
ComponentEvent | Dialog, Frame | ComponentListener:componentMoved,componentHidden,componentResized,ComponentShown | addComponentListener | ComponentAdapter |
FocusEvent | any Component | FocusListener:focusGained,focusLost | addFocusListener | FocusAdapter |
ItemEvent | Checkbox,CheckboxMenuItem,Choice,List | ItemListener:itemStateChanged | addItemListener | ItemAdjuster |
KeyEvent | any Component | KeyListener:keyPressed,keyReleased,keyTyped | addKeyListener | KeyAdapter
|
MouseEvent | Canvas,Dialog,Frame,Panel,Window. | MouseListener:mouseDragged,mousePressed,mouseClicked,mouseEntered,mouseExited | addMouseListener | MouseAdapter |
WindowEvent | Dialog,Frame. | WindowListener:windowClosing, windowOpened, windowIconified,windowDeiconified,windowClosed | addWindowListener | WindowAdapter |
MouseMovedEvent | etc |
There is also a set of MouseMovedEvents...
The Swing classes use the MVC pattern:
. . . . . . . . . ( end of section User Interface Classes) <<Contents | End>>
Input/Output
. . . . . . . . . ( end of section General Purpose Classes) <<Contents | End>>
Errors and Exceptions
. . . . . . . . . ( end of section Java Application Programmers Interface) <<Contents | End>>