• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

callbacks

 
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was reading in our Just Java book (around page 211) about Interfaces. Included in that discussion was a mention about "Callbacks". Unfortunately, they use the word "callback" in the definition.
I don't get it.
What's called back? Back from what?
The example shows a method that takes a runnable. Then there is an object that implements runnable. Finally there is an instantiation of the object. The method gets called passing the object to it.
I understand that the run method is indirectly called when you run the method.
Why is that a call back?
Thanks for any clues on this.
Pres
 
Trailboss
Posts: 23773
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The idea of a callback is that you have pass an object to a method and that method invokes methods on that class when an event occurs.
Usually, this will be some sort of listener.
I'll create an object that implements a listener interface. Then I'll pass that object to a listener method. When the appropriate event happens, a method in my listener is called.

 
Pres Brawner
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Paul.
So this is what is done with Swing, right? Event listening?
Then the "Back" part is back to object's method when the triggering event occurs.
Am I getting this?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic