How can I send back an action from the called calss to the calling class?

Posted on 2004-11-13
Last Modified: 2010-03-31
Assumed the calling calss is class A and the called class is class B. My code looks as follow:

class A{
B b = new B();

class B{
  protected void dosomework(){

How can class A catch the action from class B?

Question by:chenwei

    Author Comment

    maybe should I set á listener to listen to the called class B?

    Author Comment

    more details:

    the calling class A is JDesktopPane, the called class B is JIternalFrame. Everytime if a JInternalFrame is closed, the calling class A should know which one is closed.
    LVL 24

    Accepted Solution

    Easy, A will keep track of all created B's and put them in an ArrayList.
    Every time a B closes it calls A.amClosing(this) method ; A can identify the argument (this) as
    stored in the ArrayList.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Suggested Solutions

    Title # Comments Views Activity
    hasOne  challenge 59 63
    commonTwo  challenge 63 68
    network + 7 57
    Eclipse Neon and jdk 1.8.0 11 37
    By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
    Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
    Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
    Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now