Package

Source Code of ExampleApplet3

import java.applet.Applet;
import java.awt.Graphics;
import java.awt.HeadlessException;

import netscape.javascript.JSObject;

/**
* @author Nicholas Zakas
*/
public class ExampleApplet3 extends Applet {

    /**
     * @throws java.awt.HeadlessException
     */
    public ExampleApplet3() throws HeadlessException {
        super();
    }

    public void paint(Graphics g) {
        JSObject window = JSObject.getWindow(this);
        JSObject document = (JSObject) window.getMember("document");
        JSObject location = (JSObject) document.getMember("location");
       
        g.drawString("Title: " + document.getMember("title"), 10, 20);
        g.drawString("URL: " + location.getMember("href"), 10, 40);
       
        window.eval("getMessageFromApplet(\"Hello from the Java applet!\")");
       
    }
}
TOP

Related Classes of ExampleApplet3

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.