?
Solved

setCallBack method in swing

Posted on 2003-03-06
8
Medium Priority
?
197 Views
Last Modified: 2013-11-23
Could some one explain me about setCallBack method in swing
0
Comment
Question by:srivenky
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 35

Assisted Solution

by:TimYates
TimYates earned 100 total points
ID: 8079429
Yes....  there isn't one...

At least not in the standard Swing components...  Are you using a component written by someone else?
0
 
LVL 4

Accepted Solution

by:
thanassis earned 100 total points
ID: 8079436
if you define a callback ...

class Callback implements CallbackTarget {
     public action(Subscription sub, Notification notif) {
        System.out.println(notif);
    }
}

...you can use the setCallBack method as follows:

callback = new Callback();
sub = new Subscription("exists(CoffeeBiff)");
sub.setCallback(callback);
0
 
LVL 3

Author Comment

by:srivenky
ID: 8079707
If you could explain me the concept behind it, it would be more useful.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 35

Expert Comment

by:TimYates
ID: 8080134
Say you define an interface:

---------

interface GuffCallback
{
  public void doSomething( String woo ) ;
}

---------

Then, you can make another class that will call you back when it is done (in this case, a threaded object)

---------

public class ThreadedObject implements Runnable
{
  volatile Thread runner = null ;
  GuffCallback whenDone = null ;

  public ThreadedObject()
  {
  }

  public void setCallback( GuffCallback cb )
  {
    whenDone = cb ;
  }

  public void start()
  {
    if( runner == null )
    {
      runner = new Thread( this ) ;
      runner.start() ;
    }
  }
 
  public void run()
  {
    // do something that will take some time...
    try{ runner.sleep( 30000 ) ; } catch( InterruptedException ex ) {}
    if( whenDone != null )
    {
      whenDone.doSomething( "DONE IT!!" ) ;
    }
  }
}

---------

Then, you make your main class implement that interface, and create the thread thing to call you back...

---------

public MyMainClass extends JFrame implements GuffCallback
{

  ....
  // required for the interface...
  public void doSomething( String woo )
  {
    System.out.println( "Something called with parameter " + woo ) ;
  }
  ...

  public void doIt()
  {
    ThreadedObject obj = new ThreadedObject() ;
    obj.setCallback( this ) ;
    obj.start() ;
  }
}

---------
0
 

Expert Comment

by:CleanupPing
ID: 9058888
srivenky:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 3

Author Comment

by:srivenky
ID: 9064417
please delete this question
0
 
LVL 35

Expert Comment

by:girionis
ID: 9686901
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

- Split points between thanassis and TimYates

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

girionis
EE Cleanup Volunteer
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses
Course of the Month8 days, 21 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question