Reputation: 75
I need to pass a text from a JTextField in a JFrame to a second JTextField in another JFrame. GUI has been created using GUI Editor netbeans 6.9.
Upvotes: 1
Views: 3934
Reputation: 753
You should bind your model to both of the views (JTextFields) instead of copying Text from one to another.
Read http://www.martinfowler.com/eaaDev/OrganizingPresentations.html for more information.
Upvotes: 1
Reputation: 274532
Use textField.getText to get the text from a textfield and anotherTextField.setText to set the text of the other textfield.
If your JFrames are in two different classes you may have to expose methods in those classes to get and set the text between them.
Upvotes: 2
Reputation: 23629
getText()
of the first JTextField and setText()
on the second field.Upvotes: 4