《AppletButtonEvent.java》

//AppletButtonEvent.java
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class AppletButtonEvent extends Applet implements ActionListener
{
TextField input,output;
public void init()
{
Label prompt = new Label("input name");
Button btn = new Button("OK");
input = new TextField(6);
output = new TextField(20);
add(prompt);
add(input);
add(btn);
add(output);
btn.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
output.setText(input.getText()+",Welcome!");
}
}
<html>
<body>
<applet code=AppletButtonEvent.class width=300 height=300></applet>
</body>
</html>
上一篇:你需要了解的JS框架


下一篇:python高级特性和高阶函数