All Downloads are FREE. Search and download functionalities are using the official Maven repository.

src.gov.nasa.worldwindx.examples.applet.package.html Maven / Gradle / Ivy

Go to download

World Wind is a collection of components that interactively display 3D geographic information within Java applications or applets.

There is a newer version: 2.0.0-986
Show newest version







    World Wind Java Applets



Examples of a displaying a World Wind globe in a Java Applet. Instructions for deploying Applets and live Applet examples are available at http://goworldwind.org. Important links for Applets on goworldwind.org:

  • Get Started shows you how to deploy World Wind Applets
  • Demos showcases World Wind applets

The WWJApplet and WWJAppletMinimal classes in this package demonstate how to display a WorldWindow inside a Java Applet, and how to communicate between the Applet and the browser. The documents WWJApplet.html and WWJApplet.jnlp in the demos folder demonstrate how to embed a World Wind Applet in a web page.

Applet Parameters

Applet parameters can be specified in HTML via the applet or object tag using the param field.

    <param name="key" value="value">

The Applet can then retrieve this parameter using Applet's getParameter method.

    String value = getParameter("key");

Java-to-Javascript Communication

This section provides a basic overview of communication between a Java Applet and the browser's Javascript runtime, referred to as LiveConnect. For more information see Oracle's Java Applet tutorial at
http://docs.oracle.com/javase/tutorial/deployment/applet/index.html

Enable Java-to-Javascript Communication

Add the id and mayscript attributes to the applet tag to enable Java-to-Javascript communication. The id attribute provides a DOM Id that Javascript uses to identify the Applet. The mayscript attribute enables the browser to call Javascript functions from Java using the JSObject class.
    <script src="http://www.java.com/js/deployJava.js"></script>
    <script>
        var attributes = {id:'appletId', mayscript:'true', ...};
        var parameters = ...;
        deployJava.runApplet(attributes, parameters, '1.6'); // runApplet automatically looks for JRE 1.6+
    </script>

Call Java Methods from Javascript

    // Provide a common method for accessing the World Wind applet.
    var theApplet = null;
    function getApplet()
    {
        if (theApplet == null)
        {
            theApplet = document.getElementById('appletId'); // id attribute specified in the applet tag.
        }

        return theApplet;
    }

    // Call the Java Applet method doSomething() from Javascript.
    getApplet().doSomething();

Call Javascript Functions from Java

    import netscape.javascript.JSObject;

    // Call the Javascript doSomethingJS method from the Java Applet.
    JSObject win = JSObject.getWindow(this);
    win.call("doSomethingJS", null);

    // Evaluate and execute Javascript code as a string.
    win.eval("alert('An alert message')");




© 2015 - 2025 Weber Informatics LLC | Privacy Policy