This javaworld article describes how to create custom events and eventlisteners.
There are three main components in event-driven programming:
*EventObject class
*EventListener interface
*EventGenerator class
The EventObject class extends the java.util.EventObject class and knows the event generator object.
The EventListener interface supplies the method that is to be invoked when the event is generated.
The EventGenerator contains the list of eventlisteners registered for that event. Whenever the event is generated, it iterates through the listeners and invokes their eventlistener method eg. public void actionPerformed() for an ActionEvent.
Thursday, May 8, 2008
Undo/Redo implementation in Java
Java World Article on Undo-Redo
Swing Undo Package
For each operation undo and redo are defined and added to the UndoManager object as an UndoableEdit.
A complete example
An example with Drawing Panel
Swing Undo Package
For each operation undo and redo are defined and added to the UndoManager object as an UndoableEdit.
A complete example
An example with Drawing Panel
Subscribe to:
Comments (Atom)