Education Prize Logo
Science SPORE Prize
November 2011

NSF Logo
The Open Source Physics Project is supported by NSF DUE-0442581.


Frame Applet

The approach shown here uses the OSP Frame Applet to embed the application's main window into an html page. As is the case with the OSP Button Applet, the program author creates a java Application and need not concern him/herself with the Applet API. The same simulation runs as a stand-alone application and as an applet.

Example: The classical-physics Helium Model is embedded into an html page in this example.

At least version 1.5 of the Java Runtime is needed to run this java applet.

Frame Applet Parameters

The OSP Frame Applet acts as an intermediary that invokes an application's main method. For example, the Classical Helium application is embedded into this html page using the standard applet tag:

<applet code="org.opensourcephysics.davidson.applets.FrameApplet.class" archive="mech_helium.jar" name="framed_braided" width="300" height="350" align="top" codebase="jars"> <param name="target" value="org.opensourcephysics.davidson.twobody.HeliumWRApp" /> <param name="xmldata" value="braided.xml" /> <param name="permissions" value="sandbox" /> </applet>

The target tag specifies the name of the application that will be run by the FrameApplet. The xmldata tag specifies an initialization data file that will be passed to the HeliumWRApp application.

Note: A Java applet running within a web page can be a security threat. You should trust the author/originator of the applet and the applet should be signed with a security certificate.

Multiple Views

If a program creates multiple frames, the applet chooses the embedded view as follows:

  • The Frame Applet attempts to reads the content parameter in the applet tag. The tag is optional and curriculum author must know the names of the frames (windows) in the application. The frame's content will be embedded into the html page if it exists and can be located. Many OSP program name the window that has start and stop simulation buttons the controlFrame.
  • If the content cannot be located, the Frame Applet uses the content of the first frame that it finds. Because many applications create only a single window, this option makes it possible to embed Java applications without additional programming.

The OSP Network:
Open Source Physics - Tracker - EJS Modeling
Physlet Physics
Physlet Quantum Physics