展开全部
可以通过构62616964757a686964616fe4b893e5b19e31333365663431造方法传递给 B, 如下:import java.awt.*;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextField;
class B extends JFrame {
public B(String val) {
this.setTitle("B");
this.setSize(300, 200);
this.setLocationRelativeTo(null);
this.setLayout(new FlowLayout());
// 将 a 传过来的值 给 JTextField
JTextField txtVal = new JTextField(val);
txtVal.setPreferredSize(new Dimension(100, 23));
this.add(txtVal);
}
}
public class App extends JFrame {
String a = "123";
public App() {
this.setSize(300, 200);
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLayout(new FlowLayout());