passing struct back to parent class after "ok" click

Posted on 2003-03-25
Medium Priority
Last Modified: 2010-03-31
I'm writing a class that extends JFrame, it will accept a list of names as an array and then create corresponding check boxes and labels on the frame.  I don't have a problem getting the JFrame (optionPanel) to appear, but the question I have is how do I pass the subsequent array of Booleans (checked or not) back to the calling class after the "ok" button is clicked.  If I knew what class was going to call the optionPanel I could just set a variable in the parent class, but since optionPanel can be called from as many as 20 different classes I'm looking for a more generic way to do it.

 public class optionPanel extends JFrame{
    public optionPanel(array names){
       public void cmdOK_Click(){
I'm assuming the code I'm looking for would go into cmdClose_Click();
Question by:zephar410
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
LVL 15

Accepted Solution

JakobA earned 300 total points
ID: 8207052
Your constructor function cannot pass bac anything but the reference to your new object.

But is not that enough?  you kan place the desired dat in the class as public variables:

 public class optionPanel extends JFrame{
   public array myNames;
   public optionPanel(array names){
      myNames = names;
      public void cmdOK_Click(){
 } // end of class optionPanel

 public someOtherClass {
   optionPanel myObject;
   public sometype methodName( ) {
     myObject = new optionPanel( parameeters );
     return myObject.myNames;
 } // end og class someOtherClass

best JakobA

Author Comment

ID: 8207139
Ahh yes... a week of vacation will make one ask questions with such obvious answers :]


Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

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 contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
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…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses
Course of the Month13 days, 4 hours left to enroll

777 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