这就是问题所在。我不得不填充TextArea
在B级(tAreaB
从具有值)TextArea
在A类(tAreaA
)。
我在 A 类中这样做:
tAreaA.setText("Value A");
如何填充tAreaB
与 相同的值tAreaA
?我在 ClassB 中尝试过这个:
String value;
ClassA a = new ClassA();
value = a.tAreaA.getText();
tAreaB.setText(value);
我想你知道方法是如何工作的,所以,你唯一需要做的就是很简单......
代码:
//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.
cb.txtAreaB();
//Now, just call the object, and set the text: value.
cb.txtAreaB.setText(value);
}});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句