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 |
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 |
Serializable | void
writeObject(java.io.ObjectOutputStream out) void readObject(java.io.ObjectInputStream in) | java.io | methods are optional, uses serialVersionUID VERY Brittle |