Link to home
Start Free TrialLog in
Avatar of yongyih
yongyihFlag for Malaysia

asked on

I want to know how to pass data between JFrame

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 ^^
ASKER CERTIFIED SOLUTION
Avatar of TimYates
TimYates
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of yongyih

ASKER

I think i found the problem already. Thanks.