Java Reference
In-Depth Information
Getting ready
JavaFX applets are deployed as part of the desktop profile. Therefore, applets are capable of
using the JNLP for Web Start deployments. We will use the javafxpackager tool to generate
deployment artifacts for the sample applet presented in this recipe. If you are not familiar
with javafxpacakger, review the recipe Building and packaging your app with javafxpackager
presented earlier in this chapter. If you prefer to use an IDE for your build and deployment,
then refer to the recipe Building and packaging your app using an IDE from this chapter.
For this recipe, we will package a simple application named "applet-demo." We will use the
javafxpackager tool to build the application and generate the deployment assets, which
are expected to be provisioned from a web server using a web browser.
How to do it...
We will go through several steps to demonstrate how to build and deploy your application as a
JavaFX applet. Again, the code is intentionally kept simple, so that you can concentrate on the
packaging steps necessary to distribute the application as an applet:
1. The first step is to create your application. Here we have a small application listed
below. Refer to the file ch07/source-code/src/myapplet/SimpleApplet.fx
for complete code information.
package myapplet;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.text.Text;
import javafx.scene.text.Font;
var msg:Text = Text {
font : Font {
size : 52
embolden: true
name: "sans-serif,Arial,Helvetica"
content: "I am Browser-Embedded"
msg.translateY = msg.boundsInLocal.height;
Search WWH ::

Custom Search