问答题
import java. awt.*;
import java. awt. event. *;
import java. applet. *;
/*
< applet cede = exl_7, class width = 800 height = 400 >
</applet >
*/
public class ex]_ extends Applet implements ActionListener {
private String str = "ok";
private Label |;
private Button btn;
public void init( ) {
(1)
I = new Label(str);
I. reshape(10, 10, 150, 30);
add(I);
(2)
btn. reshape(10, 50, 60, 20);
(3)
add(btn);
btn = new Button(" Second" );
btn. reshape(10, 100, 60, 20);
(4)
btn, addActionListener(this);
add(btn);
}
public void actionPerformed(ActionEvent ae) {
str = " Command:" +ae. getActionCommand( )
(5)
ex1_7, html
< HTML >
< HEAD >
< TITLE > ext _7 </TITLE >
</HEAD >
< BODY >
< appletcode =" ext. class" width =800 height =400 >
</applet >
</BODY >
</HTML >