Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

custom events and listening to them 1

Status
Not open for further replies.

Sedai

Programmer
Mar 4, 2001
158
US
I've created a custom event
alert = new WindowEvent(parent, AWTEvent.RESERVED_ID_MAX+1);

if obj is a reference to the object that i want to receive the event and i type obj.dispatchEvent(alert) is that sending the event to obj?

If it does, how can I detect that event.
I tried
enableEvents(AWTEvent.RESERVED_ID_MAX+1);
processEvent(alert);

then i have addWindowListener(new WindowAdapter(){
public void listenForAlert(WindwoEvent e){
//code
}
});

that doesn't work, and it was quite unlikely it would but i tried hehe. anyway, how can i create a custom listener. I'm not even sure if i'm on the right track here.

thank you!

Avendeval


 
I do not think this is the usual way of processing events. Window events usually get generated by Window Event producers (like Window) and get processed by classes implementing WindowListener.

WindowAdapter myWindowListener = new WindowAdapter(myWindow) {
void windowClosing(WindowEvent e) {...window closing code...}
};

You may be better writing your own event source / listener class pair rather than trying to fit it into the Window framework.
 
shoot of course, duh, it's so obvious hehe.
i should extend my own Listener class. thanks a lot. i worked around that and don't need the special event/listener anymore, but still it's good to know. im still not used to JAVA hehe. thank a lot.
Avendeval


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top