You probably want to create an javax.swing.EventListenerList. Here's the
javadocs.
* Usage example:
* Say one is defining a class that sends out FooEvents, and one wants
* to allow users of the class to register FooListeners and receive
* notification when FooEvents occur. The following should be added
* to the class definition:
* <pre>
* EventListenerList listenerList = new EventListenerList();
* FooEvent fooEvent = null;
*
* public void addFooListener(FooListener l) {
* listenerList.add(FooListener.class, l);
* }
*
* public void removeFooListener(FooListener l) {
* listenerList.remove(FooListener.class, l);
* }
*
*
* // Notify all listeners that have registered interest for
* // notification on this event type. The event instance
* // is lazily created using the parameters passed into
* // the fire method.
*
* protected void fireFooXXX() {
* // Guaranteed to return a non-null array
* Object[] listeners = listenerList.getListenerList();
* // Process the listeners last to first, notifying
* // those that are interested in this event
* for (int i = listeners.length-2; i>=0; i-=2) {
* if (listeners[i]==FooListener.class) {
* // Lazily create the event:
* if (fooEvent == null)
* fooEvent = new FooEvent(this);
* ((FooListener)listeners[i+1]).fooXXX(fooEvent);
* }
* }
* }
* </pre>
* foo should be changed to the appropriate name, and fireFooXxx to the
* appropriate method name. One fire method should exist for each
* notification method in the FooListener interface.
-----Original Message-----
From: Reinstein, Lenny
To: '[EMAIL PROTECTED]'
Sent: 11/16/01 1:00 PM
Subject: Generating events in Swing.
Can someone remind me how to generate Action events that I want to catch
somewhere else?
I.e., the common scenario is that you add action listener to, say, a
button,
and then handle it with the actionPerformed method. What I need to do is
to
generate another event when this first event is caught.
Button "OK" is clicked ---> do something --> generate another event X
-->
catch that event in another component
Thanks!
_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing
_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing