callback methods in java
2 posts in topic
Flat View  Flat View

Posted By:   manikandan_chipcd
Posted On:   Friday, February 29, 2008 04:04 AM

can anyone please tell me the concept of callback methods and example of callback methods in "java"?

Re: callback methods in java

Posted By:   Robert_Lybarger  
Posted On:   Friday, February 29, 2008 07:59 PM

In a nutshell, "callback" methods are used to arrange for something you are doing in one area of the code to inform you that something has happened: progress being made, an error happening, a user selection, etc. In general, that little "something you are doing" is still in the process of executing. More abstractly, it is like a parenthetical thought (hey, like this!) added in the middle of a sentence.

In Java, this shows up most obviously in the UI event handling routines. You say: "when this button is pressed, I want this code to execute in response." In this case, you register an implementation of a particular interface (ActionListener's actionPerformed method) on the button in question. When the end-user clicks the button, that part of the code you don't control -- the event dispatching thread -- calls code in your callback method that you *do* control to do something interesting. Also, parsing XML using a SAX-based approach is ripe with callback methods as the parser lets you know what sort of node it has encountered while reading the file. And so forth.

Re: callback methods in java

Posted By:   Stephen_McConnell  
Posted On:   Friday, February 29, 2008 09:47 AM

Here's an article that explains Implementing CallBack Methods

Hope this helps.

Stephen McConnell

About | Sitemap | Contact