We help IT Professionals succeed at work.

I want to know how to pass data between JFrame

yongyih
yongyih asked
on
I want to know how to pass data between 2 JFrame.

For example,
main menu (Jframe) load another JFrame called loadFiles.
I want the loadFiles to return 3 String.  How to do this?

I try to put that three String in a class and pass to the loadFiles constructor.  The problem is i cannot access in button's ActionListener.  The error message is cannot access in inner class.

public class Test{
  private MyData myData;
  public Test(MyData myData){ // pass from main menu
    this.myData=myData;
    // other coding here..
  }
}

    cmdOk.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent e){
         // here
         myData.setName(txtName.getText());
      }
    });

Any idea how to solve this problem??
Hopefully you guys can understand my question ^^
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2004
Commented:
You tried:

  MainClass.MyData

?

If not, more code is required...I can't really see enough of what you are trying to do, or where your problem lies :-(

Tim.

Author

Commented:
I think i found the problem already. Thanks.