服务热线:13616026886

技术文档 欢迎使用技术文档,我们为你提供从新手到专业开发者的所有资源,你也可以通过它日益精进

位置:首页 > 技术文档 > JAVA > 新手入门 > 基础入门 > 查看文档

java核心代码例程之:simpleapplet.java


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;
    }
}

扫描关注微信公众号