Home Get Value from JTextArea in Another Class
Reply: 1

Get Value from JTextArea in Another Class

Henry Wilson
Henry Wilson Published in 2018-02-14 04:58:11Z

Here's the problem. I had to fill a TextArea in Class B (tAreaB) with a value from TextArea in Class A (tAreaA).

I'm doing this in Class A:

tAreaA.setText("Value A");

How can I fill the tAreaB with same value as tAreaA? I have tried this in ClassB:

String value;
ClassA a = new ClassA();
value = a.tAreaA.getText();
Sthatyc Soul.
Sthatyc Soul. Reply to 2018-02-15 04:27:48Z

I suppose that you know how works methods, so, the only thing that you need to do is very simple...


//Class A - button's - ActionListener.
button.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent A){

//Create a empty variable: String, with the name of: value.
String value = "";

//Value, gets the text of the: txtAreaA.
value = txtAreaA.getText();

//Calls the: classB, and create a new object from them.
classB cb = new classB();

//cb.txtAreaB(); is the method who creates a: JFrame, with JTextArea, in classB.

//Now, just call the object, and set the text: value.
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.296222 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO