JavaFXPluginAppletDeploymentSpecification

Revision as of 12:47, 5 November 2009 by Admin (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)

JavaFX Plugin - Applet Deployment Specification

Document Status Initial Draft


Contents


Introduction

Applet Deployment provides a way to deploy a JavaFX Script applet in a platform-independent way using applet viewer. Applet distribution type is special form of application that can be included in html page and executed by html browser.

Creating JavaFX Script applet

To create JavaFX Applet, create new JavaFX Project or open existent one. After that, you can use two ways to create the JavaFX Applet:

  • Right-click a JavaFX project and select on popup-menu "New" > "JavaFX Applet" items like shown in the figure below:

Applet Deployment

OR

  • Select menu File > New File. You will see the "New File" window like shown in the figure below. Please select JavaFX in "Categories" and JavaFX Applet in "File Types" (illustrated in the figure below):

Applet Deployment

JavaFX Script Applet template

Since JavaFX Script Applet specification (javafx.ui.Applet) does not define any specific mandatory methods, JavaFX Applet template can be very simple and look as follows:

/*
 * <JavaFX_Applet_title>.fx
 *
 * Created on <date> <time>
 */

package <package_title>;

import javafx.ui.Applet;

/**
 * @author <author>
 */

public class NewJavaFXApplet extends Applet{
    // place your code here  

}

Run JavaFX Script applet

When work on the applet code is finished, it could be deployed in the following way:

  • Right-click an applet class in the Projects window or Files window.
  • Select Run File from the pop-up menu like it is shown on the figure below:

Applet Deployment

The run-single build target should call some java code which is able to check the selected fx file and make a decision if this is an applet or not. When corresponding method (isApplet) returns true, the run-applet target is being called.

The run-applet build target performs the following operations:

  • Compiles applet source
  • Copies libraries needed to run the JavaFX Script applet to build/lib folder (such as javafxrt.jar, Scenario.jar)
  • Creates the HTML launcher file with corresponding <APPLET /> tag embedded to launch the applet. The HTML launcher file is created in the build folder. The launcher looks like the follows:

NewJavaFXApplet.html

<HTML>
<HEAD>
   <TITLE>Applet HTML Page</TITLE>
</HEAD>
<BODY>

<H3><HR WIDTH="100%">Applet HTML Page<HR WIDTH="100%"></H3>

<P>
<APPLET codebase="classes" code="javafxapplication/NewJavaFXApplet.class" width=350 height=200
archive="./lib/javafxrt.jar,./lib/Scenario.jar"></APPLET>
</P>

<HR WIDTH="100%"><FONT SIZE=-1><I>Generated by NetBeans IDE</I></FONT>
</BODY>
</HTML>

To run an applet with the parameters you should move the launcher file from the build folder to the src folder and put in near the applet class. Now you can edit the html file manually. Make sure that the launcher file has the same name as the applet class. When editing is finished, build the applet. The launcher file will be copied to the build folder.

  • Creates applet.policy file to grant run permission to the applet:
grant {
    permission java.security.AllPermission;
};

This file is created in the root directory of the project (near build.xml file). If necessary, this file could be edited manually later. Build procedure should check if the applet.policy file exists already and be sure to keep the existent file.

  • Launches AppletViewer passing to it as a parameter URL of the created HTML file

The figure below illustrates the example of applet being run

Applet Deployment

Note: that this document covers only JavaFX Script Applet specific functionality. You can find more information regarding Applet creation and run in general in NetBeans IDE online help (in particular, operating with applet.policy and HTML launcher files).

Debug JavaFX Script applet

TBD

Sign JavaFX Script applet

TBD

The jar file created using default build target should contain the JavaFX Script Applet related classes. The signing of this jar file is under discussion so far. Not sure if this functionality should be added to the IDE. Note that signing of J2SE Applets is not supported in NetBeans IDE currently.

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo