• Post Reply Bookmark Topic Watch Topic
  • New Topic

java callback  RSS feed

 
Arthur King
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can anyone give me a brief introduction on how callback works on java or any links.thanks
 
Peter Tran
Bartender
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Arthur,
I think an example will help answer your question.

-Peter
 
timothy zimmerman
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I understnad this example but also have a question about it. I understand that you are limiting what access the worker has by passing the the instance of the Boss object as the Callable interface. This limits worker to accessing only those methods declared in the Callable interface correct?
What is the advantage of this ( if any ) other than the obivous restrictions? Are there other reasons not to pass the Boss object as a Boss object?
 
Arthur King
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
peter,
thank you so much for the help, i think i have got some understanding about the basic concept of callback, it will be much greater if you can give me / or tell me where i can find more examples. thanks.
arthur
 
Johannes de Jong
tumbleweed
Bartender
Posts: 5089
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Arthur
Google search callback example java. 17,300 hits take your pick.
 
vineet kaushik
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It helped to eradicate the confusion on Call back for me.. Thanks for sharing..
 
Nate Lockwood
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm really confused.
I've been looking for a good example of how to implement a callback method and found this explanation (and others) but it's not clear to me in my context.

I have a class/app, ImageDisplay.java in which the user can click on a menu item and create an instance of a class UserStretch.java. The user can click on a button in UserStretch to tell ImageDisplay to re-display the image with changed parameters, that is, if I could implement the callback.

I've created the interface Callable.java but don't quite understand how the other classes map to my two classes. Is one of them an inner class?

It appeared to me that that the Worker class maps to my UserStretch Class and the Boss class maps to my ImageDisplay class but then what about the CallBack class.

I know I'm replying to an old post ...
 
Nate Lockwood
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I finally figure it out. Here's how I did it:

In the class being notified:


The class making the notification:


 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nate Lockwood wrote:I finally figure it out. Here's how I did it:

Well done...but I suspect you can improve on that with the right interface and generics.

Winston
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!