aspose file tools*
The moose likes Java in General and the fly likes How to create user defined and customized call back method in core java? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to create user defined and customized call back method in core java?" Watch "How to create user defined and customized call back method in core java?" New topic
Author

How to create user defined and customized call back method in core java?

jacob deiter
Ranch Hand

Joined: Apr 02, 2008
Posts: 576
How to create user defined and customized call back method in core java??
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Can you be more specific?
jacob deiter
Ranch Hand

Joined: Apr 02, 2008
Posts: 576
If want to create any user define Session listener then I have implement Session listener Interface, Like that, in swing, Mouse listener, we have to implement listener interface sun provided

But I do not want theirs listener and want to own listener, how it can be created??
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18902
    
    8

You would do it basically the same way as those interfaces you mentioned do it. What part of this are you having trouble with?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39828
    
  28
I don't think callbacks are a "beginning" question. Moving thread.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19760
    
  20

The event listener frame work works as follows:
- Create a subclass of EventObject (or any of its subclasses like ActionEvent), let's call it MyEvent
- Create a subinterface of EventListener (or any of its subinterfaces like ActionListener), let's call it MyListener
- Give MyListener one method for each type of event with MyEvent as the parameter:

- If your listener has more than one method and you like your users, create an adapter with empty-body implementations:
That way, users only need to override the methods they need to implement.

As for calling the listeners, there are two ways:
1) use a List<MyListener>:
2) use an EventListenerList:
I'd go for EventListenerList if you need more than one listener type.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to create user defined and customized call back method in core java?