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:
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 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");
This section provides a basic overview of communication between a Java Applet and the browser's Javascript runtime.
For more information see Oracle's Java-to-Javascript Communication page at:
http://docs.oracle.com/javase/7/docs/technotes/guides/plugin/developer_guide/java_js.html
<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>
// 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();
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')");