Create a text field in sample1.java with JTextField text=newJTextField();
and press the button to move another class (textget) program in sample2.java. I wrote (wanted) a program to get a string in the text field in getText(), but simply cannot get a string from the String=text;text(text);Please tell me how to write it.
It is difficult to getText()
the text fields of another class.
In sample1.java, add a method to retrieve the text field and place
String str=this.text.getText();
return str;
I think you can do it if you write thatAfter that, I think you can call from sample2.java.
Of course, there will be an error in this case, so the sample1.java field will be
JTextField text=newJTextField();
I think I can compile it if I write like this.
© 2024 OneMinuteCode. All rights reserved.