Java核心代码例程之:SimpleApplet.java
2008-01-05 08:38:11 来源:WEB开发网核心提示:import java.applet.*;import java.awt.*;/** This demo uses JDK 1.0 event model for browser compatibilityHere is the supporting Html code:<applet code=SimpleAp
import java.applet.*;
import java.awt.*;
/** This demo uses JDK 1.0 event model for browser compatibility
Here is the supporting Html code:
<applet code=SimpleApplet width=200 height=100></applet>
**/
public class SimpleApplet
extends Applet
{
Label l = new Label("Please click the button", Label.CENTER);
Button b = new Button("Click it!");
public void init()
{
setLayout(new BorderLayout());
add("Center", b);
add("South", l);
}
public boolean action(Event event, Object what)
{
if (event.target == b)
{
l.setText("Hello World!");
return true;
}
return false;
}
}
更多精彩
赞助商链接