日期:2014-05-20 浏览次数:20689 次
import java.awt.Frame;
import java.awt.Label;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;
public class Test3 extends Frame implements ActionListener {
Label prompt;
TextField input, output;
public void init() {
prompt = new Label("请输入你的专业:");
input = new TextField(8);
output = new TextField(16);
add(prompt);
add(input);
add(output);
input.addActionListener(this);
setSize(500, 400);
setVisible(true);
}
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(null, "你喜欢吗?", "友情提醒",
JOptionPane.QUESTION_MESSAGE);
output.setText("好好学" + input.getText());
}
public static void main(String args[]) {
new Test3().init();
}
}