Search code examples
javaswingjframejtextfield

How to pass data from a JTextField to another JTextField


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.


Solution

  • 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.