首页 > 学院 > 开发设计 > 正文

Java核心代码例程之:SimpleApplet.java

2019-11-18 15:16:46
字体:
来源:转载
供稿:网友

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

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表