Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


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

Posted on 2004-11-13
Medium Priority
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
  • 2

Author Comment

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

Author Comment

ID: 12575196
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

sciuriware earned 200 total points
ID: 12575434
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.

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
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 will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month15 days, 9 hours left to enroll

580 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