Here's a good link on the "theory" behind the Java event model:
And here's a link illustrating how to create your own, custom events:
And here's a really good example from SO:
// REFERENCE: https://stackoverflow.com/questions/6270132/create-a-custom-event-in-java
import java.util.*;
interface HelloListener {
public void someoneSaidHello();
}
class Initiater {
List<HelloListener> listeners = new ArrayList<HelloListener>();
public void addListener(HelloListener toAdd) {
listeners.add(toAdd);
}
public void sayHello() {
System.out.println("Hello!!");
// Notify everybody that may be interested.
for (HelloListener hl : listeners)
hl.someoneSaidHello();
}
}
class Responder implements HelloListener {
@Override
public void someoneSaidHello() {
System.out.println("Hello there...");
}
}
class Test {
public static void main(String[] args) {
Initiater initiater = new Initiater();
Responder responder = new Responder();
initiater.addListener(responder);
initiater.sayHello();
}
}
The key is:
1) create an "interface" that defines your "event" (such as the events in the AWT event model)
2) create a class that "implements" this event (analogous to "callbacks" in languages like C - and effectively what VB does for you automagically with the "Event" type).
'Hope that helps ... at least a little bit!