package cn.homework;
import java.awt.FlowLayout;
import java.awt.TextArea;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextField;
public class Demo_third {
/**
* @param args
*/
public static void main(String[] args) {
JFrame jf = new JFrame("我的窗口");
jf.setSize(500, 400);
jf.setLocation(450, 200);
jf.setLayout(new FlowLayout());
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final JTextField jtf = new JTextField(30);
JButton jb = new JButton("转到");
final TextArea ta = new TextArea();
jb.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
String lan = jtf.getText();
ta.append(lan + "\r\n");
jtf.setText("");
}
});
jf.add(jtf);
jf.add(jb);
jf.add(ta);
jf.setVisible(true);
}
}
|
|