Interfaces - Survey - Musings



Survey.

Let me begin by listing some of the interfaces available in the JDK, the methods they define, and a few comments. The basic Java class libraries define over 3000 classes, and hundreds of interfaces, so this list is far from compete.

Interface methods Package Comments
ActionListener void actionPerformed(ActionEvent e) java.awt.event Covers most actions in the AWT
KeyListener void keyPressed(KeyEvent e)
void keyReleased(KeyEvent e)
void keyTyped(KeyEvent e)
java.awt.event Covers key presses, bypasses command line editor
MouseListener void mouseClicked(MouseEvent e)
void mouseEntered(MouseEvent e)
void mouseExited(MouseEvent e)
void mousePressed(MouseEvent e)
void mouseReleased(MouseEvent e)
java.awt.event Covers click-oriented mouse event
MouseMotionListener void mouseDragged(MouseEvent e)
void mouseMoved(MouseEvent e)
java.awt.event Covers mouse moving type events - use very short code here, otherwise application will really slow down.
Comparable <T>
int compareTo(T o) java.lang natural ordering for class, see Comparator below
Comparator <T>
int compare(T t1, T t2)
boolean equals(T t)
java.util A class can have more than one of these. Access to T fields can be gained using t, t1 and t2 references.
An instance of this class can be used effectively as a parameter to sort in the packages Arrays and Collections:
public static <T> void sort​(
  List<T> list,
  Comparator<? super T> c)

Enumeration boolean hasMoreElements()
E nextElement()
java.util Use:
// v is an enumberable class, such as Vector
for (Enumeration e = v.elements() ; e.hasMoreElements() ;) {
System.out.println(e.nextElement());
} // end for each element
Iterable Iterator iterator() java.lang variety of subinterfaces, Collections classes and others use this
Iterator boolean hasNext()
E next()
void remove()
java.util similar to enumeration, but adds remove()
Runnable void run() java.lang Place where a thread starts
EventListener (none) java.util LOTS of subinterfaces and implementing classes
Paint PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform xform, RenderingHints hints) java.awt NOT the paint (Graphics) method used in GUI's
Serializablevoid writeObject(java.io.ObjectOutputStream out)
void readObject(java.io.ObjectInputStream in)
java.iomethods are optional, uses serialVersionUID
VERY Brittle

Complete set of interfaces in a few packages:

Package InterfacesPackageInterfacesPackageInterfaces
java.util Collection
Comparator
Deque
Enumeration
EventListener
Formattable
Iterator
List
ListIterator
Map
Map.Entry
NavigableMap
NavigableSet
Observer
Queue
RandomAccess
Set
SortedMap
SortedSet
java.langAppendable
AutoCloseable
CharSequence
Cloneable
Comparable
Iterable
Readable
Runnable
Thread.UncaughtExceptionHandler
java.ioCloseable
DataInput
DataOutput
Externalizable
FileFilter
FilenameFilter
Flushable
ObjectInput
ObjectInputValidation
ObjectOutput
ObjectStreamConstants
Serializable
java.awt ActiveEvent
Adjustable
Composite
CompositeContext
ItemSelectable
KeyEventDispatcher
KeyEventPostProcessor
LayoutManager
LayoutManager2
MenuContainer
Paint
PaintContext
PrintGraphics
SecondaryLoop
Shape
Stroke
Transparency
java.awt.eventActionListener
AdjustmentListener
AWTEventListener
ComponentListener
ContainerListener
FocusListener
HierarchyBoundsListener
HierarchyListener
InputMethodListener
ItemListener
KeyListener
MouseListener
MouseMotionListener
MouseWheelListener
TextListener
WindowFocusListener
WindowListener
WindowStateListener



ND.