*
* @author
* @version 1.00 2007/9/22
*/
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class A1 extends Applet implements ActionListener{
Label xm;
TextField sxm,ssxm;
Button tj;
public void init(){
xm= new Label("");
sxm= new TextField(6);
ssxm= new TextField(20);
tj =new Button("Enter");
add(xm);
add(sxm);
add(ssxm);
add(tj);
tj.setSize(50,50);
xm.setText("aaaa:");
tj.addActionListener(this);
ssxm.addActionListener(this);
}
public void paint(Graphics g){
g.draw3DRect(1,1,400,200,true);
g.drawString(xm.getText()+sxm.getText()+ssxm.getText(),120,220);
}
public void actionPerformed(ActionEvent e)
{
Graphics g;
if (e.getSource().equals(ssxm) ){
sxm.setText("OK");
}
ssxm.setText(sxm.getText().toUpperCase()+"aaaa");
repaint();
}
}
编译生成*.class
然后生成一个网页代码如下:
<html>
<body>
<applet CODE="A1.class" width=420 height=220 >
aaaaaaaaa</applet>
</body>
</html>
两都放在同一位置