【发布时间】:2019-04-24 19:47:28
【问题描述】:
这是我迄今为止尝试过的:
{
TextField tf;
JTextArea ta;
public TextListener()
{
gui();
}
public void gui()
{
JFrame f = new JFrame();
JPanel p = new JPanel();
tf = new JTextField("",20);
ta = new JTextArea("",20,20);
JButton b = new JButton("SHOW");
f.add(p);
p.add(tf);
p.add(b);
p.add(ta);
f.setVisible(true);
f.setSize(400,200);
f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}
public void actionPerformed(ActionEvent ae)
{
String name = tf.getText();
ta.append(name);
}
public static void main(String[] arg)
{
new TextListner();
}
【问题讨论】:
-
不要发布您的代码图片。以minimal reproducible example 的形式发布实际代码。
标签: java swing user-interface