| Document Status | Initial Draft |
|---|
To create JavaFX Applet, create new JavaFX Project or open existent one. After that, you can use two ways to create the JavaFX Applet:
OR
/*
* <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
}
When work on the applet code is finished, it could be deployed in the following way:
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:
<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.
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.
The figure below illustrates the example of applet being run
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).
| AppletCreateFrame.png | ![]() |
39625 bytes |
| AppletCreateMenu.png | ![]() |
37837 bytes |
| RunApplet.png | ![]() |
30644 bytes |
| RunningViewer.png | ![]() |
8557 bytes |