I have two JFrame
within a project.
In JFrame1
I have one JTextField
(JFrame1_JTextField
) and one Button. In another JFrame
I have only one JTextField
(JFrame2_JTextField
).
When I run the program and enter text in JFrame1_TextField
and click the button, I want the text to be displayed in JFrame2_JTextField
. But no text is displayed in the second JFrame
.
I am not getting any error but I am also not getting the expected output.
Expected output: I want the text entered in JFrame1_JtextField
to be set into JFrame2_JTextField
after clicking the button.
private void ButtonActionPerformed(java.awt.event.ActionEvent evt) {
new JFrame2().JFrame2_JTextField.setText(this.JFrame1_JTextField.getText());
new JFrame2().setVisible(true);
}