Starting with init()

The init() method of an applet automatically is handled once when the applet first starts to run. This method is used to assign values to the arrays pageTitle and pageLink. It also is used to create a clickable button that appears on the applet. The method consists of the following statements:

public void init() {
    pageTitle = new String[] {
        "Sun's Java site",
        "Cafe au Lait",
        "JavaWorld",
        "Java in 24 Hours",
        "Sams Publishing",
        "Workbench"
        };
    pageLink[0] = getURL("http://java.sun.com");
    pageLink[1] = getURL("http://www.ibiblio.org/javafaq");
    pageLink[2] = getURL("http://www.javaworld.com");
    pageLink[3] = getURL("http://www.java24hours.com");
    pageLink[4] = getURL("http://www.samspublishing.com");
    pageLink[5] = getURL("http://workbench.cadenhead.org");
    Button goButton = new Button("Go");
    goButton.addActionListener(this);
    FlowLayout flow = new FlowLayout();
    setLayout(flow);
    add(goButton);
}

The title of each page is stored in the six elements of the pageTitle array, which is initialized using six strings. The elements of the pageLink array are assigned a value returned by the getURL() method, yet to be created.

The last seven statements of the init() method create and lay out a button labeled “Go” in the applet window.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.217.17