|
- package pack;
- import java.awt.Button;
- import java.awt.Frame;
- import java.awt.TextArea;
- import java.awt.TextField;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- public class Myqq implements ActionListener {
- Frame f = new Frame();
- Button b = new Button("发送");
- TextField t = new TextField();
- TextArea ta = new TextArea();
- String s = "";
- Myqq() {
- f.setVisible(true);
- f.setBounds(20, 40, 500, 500);
- f.setLayout(null);
- ta.setBounds(20, 40, 400, 300);
- t.setBounds(20, 350, 400, 100);
- b.setBounds(430, 350, 50, 20);
- b.addActionListener(this);
- t.addActionListener(this);
- f.add(ta);
- f.add(t);
- f.add(b);
- }
- public void actionPerformed(ActionEvent e) {
- s = s + t.getText() + "\n";
- ta.setText(s);
- t.setText("");
- }
- public static void main(String[] args) {
- Myqq mq = new Myqq();
- }
- }
复制代码
|
|