freehandapplet.java~1~

来自「applet java 的编程程序」· JAVA~1~ 代码 · 共 117 行

JAVA~1~
117
字号
package chapter11;

import java.awt.*;
import java.awt.event.*;
import java.applet.*;

public class FreeHandApplet
    extends Applet
{
    boolean isStandalone = false;
    BorderLayout borderLayout1 = new BorderLayout();
    String var0;
    String var1;

    //Get a parameter value
    public String getParameter(String key, String def)
    {
        return isStandalone ? System.getProperty(key, def) :
            (getParameter(key) != null ? getParameter(key) : def);
    }

    //Construct the applet
    public FreeHandApplet()
    {
    }

    //Initialize the applet
    public void init()
    {
        try
        {
            var0 = this.getParameter("param0", "");
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
        try
        {
            var1 = this.getParameter("param1", "");
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
        try
        {
            jbInit();
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }

    //Component initialization
    private void jbInit()
        throws Exception
    {
    }

    //Start the applet
    public void start()
    {
    }

    //Stop the applet
    public void stop()
    {
    }

    //Destroy the applet
    public void destroy()
    {
    }

    //Get Applet information
    public String getAppletInfo()
    {
        return "Applet Information";
    }

    //Get parameter info
    public String[][] getParameterInfo()
    {
        java.lang.String[][] pinfo =
            {
            {
            "param0", "String", ""},
            {
            "param1", "String", ""},
        };
        return pinfo;
    }

    //Main method
    public static void main(String[] args)
    {
        FreeHandApplet applet = new FreeHandApplet();
        applet.isStandalone = true;

        Frame frame;
        frame = new Frame();
        frame.setTitle("Applet Frame");

        frame.add(applet, BorderLayout.CENTER);

        applet.init();
        applet.start();
        frame.setSize(400, 320);
        Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
        frame.setLocation( (d.width - frame.getSize().width) / 2,
                          (d.height - frame.getSize().height) / 2);
        frame.setVisible(true);
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?