Documentation



Oracle Java SE Embedded: Developer's Guide

14 Develop Headful Applications

We recommend that you use the JavaFX API to create headful applications. If you prefer, Oracle Java SE Embedded provides an AWT/Swing configuration for ARM.

This chapter contains the following topics:

Headful Applications Using JavaFX

JavaFX is based on the scene graph construct, takes advantage of hardware acceleration, and supports animation. You can learn about JavaFX technology by visiting the Java SE Client Technologies page.

Figure 14-1 shows an example of a JavaFX headful application running on an embedded device.

Figure 14-1 City Explorer Example

Description of Figure 14-1 follows
Description of "Figure 14-1 City Explorer Example"

Figure 14-2 shows a photo of a typical embedded touch device. Oracle Java SE Embedded supports multitouch events on supported devices. See Oracle Java SE Embedded Release Notes for devices that are supported for multitouch events.

Figure 14-2 Example Touch Device

Photogrph of a touch device

A JavaFX GUI application can reference APIs from any Java library. For example, a JavaFX application can call Java API libraries to access native system capabilities or to communicate with other embedded applications.

The look and feel of JavaFX applications can be customized. Cascading Style Sheets (CSS) separate appearance and style from implementation so that developers can concentrate on coding. Graphic designers can easily customize the appearance and style of the application through the CSS.

Because the desktop and embedded JavaFX APIs are compatible, you can do most GUI design and functional testing on a host computer, then copy the application to the target for final testing and tuning. For a quick view of the development process, see Quick Start for Application Developers.

Areas where behavior differs between embedded and desktop JavaFX platforms include the following:

  • Embedded graphics processing units (GPUs) are typically much less powerful than desktop GPUs. A less powerful GPU can lead to decreased performance in some applications.

  • UI controls can have a different appearance and behavior on embedded platforms depending on whether or not there is a touch interface.

  • On embedded platforms, JavaFX provides a virtual keyboard for text input by users and for testing.

JavaFX Components for Oracle Java SE Embedded

In order to minimize the JRE, the JavaFX APIs are divided into two components:

You must know which JavaFX component is included in the custom JRE for your application to run successfully on the target device.

JavaFX Graphics Component

JavaFX applications with effect and animation run on a JRE that is built with the Graphics component. The Graphics component supports windows, scene graph, animation, timelines, and property binding. The Graphics component does not support events or UI controls. A typical application running on a JRE that contains only the Graphics component can display effects and animation but cannot handle user input.

The Graphics component that is installed into a custom JRE with Oracle Java SE Embedded includes the Base component, as described on the Projects and Components page of the OpenJFX website.

The Graphics component's static footprint is about 6 MB.

Table 14-1 shows the packages included in the Graphics component.

Table 14-1 JavaFX Graphics Component Packages

Package Description

javafx.animation

Animation

javafx.application

Lifecycle

javafx.beans

JavaFX beans

javafx.beans.binding

JavaFX bean property binding

javafx.beans.property

Read-only and read-write bean properties

javafx.beans.value

Observable and writable values

javafx.collections

JavaFX observable collections

javafx.concurrent

Threading classes

javafx.css

Styleable properties

javafx.event

Event handling

javafx.geometry

2D and 3D

javafx.scene

Scene graph core

javafx.scene.canvas

Immediate mode rendering

javafx.scene.effect

Visual effects

javafx.scene.image

Loading and displaying images

javafx.scene.input

Input events

javafx.scene.layout

Scene layout

javafx.scene.paint

Colors and gradients

javafx.scene.shape

2D and 3D shapes

javafx.scene.text

Text rendering and metrics

javafx.scene.transform

2D and 3D transformations

javafx.stage

Windowing

javafx.util

Utilities

javafx.util.converter

String converters


JavaFX Controls Component

The Controls component adds support for UI controls, event handling, and charts. The Controls component also includes the FXML component, described on the Projects and Components page of the OpenJFX website. In addition, installing the Controls component in the custom JRE automatically includes the Graphics component.

The total footprint of the Controls component plus the other components installed with it is about 9 MB.

Table 14-2 shows the JavaFX packages included in the Controls component.

Table 14-2 JavaFX Controls Component Packages

Package Description

javafx.fxml

FXML

javafx.scene.chart

Charts

javafx.scene.control

UI controls

javafx.scene.control.cell

Cells for UI controls


Configuring Fonts

See https://wiki.openjdk.java.net/display/OpenJFX/Font+Setup for information about configuring fonts for JavaFX applications.

Unsupported JavaFX Features

The Graphics and Controls components are a large subset of JavaFX. Compared to the desktop version, the JavaFX components included in Oracle Java SE Embedded have the following restrictions:

  • They do not support the WebView node (a scene graph node for displaying and interacting with web content).

  • They do not support applets, Swing integration, or Standard Widget Toolkit (SWT) integration.

  • They do not have the MediaView class or any support for media playback.

  • They do not support APIs related to integration with a desktop UI (for example, access to a global clipboard, window decorations or iconization, file and directory choosers).

  • The embedded version of the JavaFX virtual keyboard supports only the US English locale.

  • When running with the compact1 profile (see Compact1 Profile APIs), JavaFX components do not support user interfaces defined with FXML, including those generated by JavaFX Scene Builder.

Table 14-3 lists JavaFX desktop packages that are not present in either of the two Oracle Java SE Embedded JavaFX components.

Table 14-3 JavaFX Packages not Available in Oracle Java SE Embedded

Package Description

javafx.beans.property.adapter

Integration with JavaBeans

javafx.embed.swing

Integration with the Swing API

javafx.embed.swt

Integration with the SWT API

javafx.print

Printing

javafx.scene.media

Media playback

javafx.scene.web

Web content

netscape.javascript

JavaScript integration


Using FXML Markup Instead of JavaFX APIs

If you have a web design background, or if you would like to separate the user interface (UI) and the back-end logic, then you can use FXML to develop the presentation aspects of the UI.

FXML is an XML-based language that provides the structure for building a user interface separate from the application logic of your code. This separation of the presentation and application logic is attractive to web developers because they can assemble a user interface that takes advantage of Java components without mastering the code for fetching and filling in the data.

Note:

All but the compact1 profile can use FXML See About Compact Profiles.

To see how to use FXML and integrate it into a JavaFX application, see the Java SE Client Technologies page.

Using JavaFX Scene Builder to Design the UI and Export to FXML

If you prefer to design UIs without writing code or FXML directly, then use JavaFX Scene Builder. As you build the layout of your UI, Scene Builder generates the FXML code for the layout, which is then integrated into a JavaFX application that contains the application logic.

For links to JavaFX Scene Builder documentation, see the Java SE Client Technologies page.

Note:

The compact1 profile cannot use JavaFX Scene Builder because the underlying FXML output is not supported.

JavaFX Sample Applications

The JavaFX sample applications download zip file contains Ensemble 8, a sample that was tested on embedded platforms that support JavaFX and have JREs that were built with the graphics component. Note that the 3DViewer and Modena samples are known not to run on embedded devices.

To access the Ensemble 8 sample, download the JavaFX samples by following the link from the Java SE downloads page at http://www.oracle.com/technetwork/java/javase/downloads/

Once you have extracted the sample JAR file from the sample zip file, you can double-click it to run it on your host machine. Use the following procedure to run the sample on a target device that is supported for JavaFX and is running a JRE that was built with the graphics component.

  1. Transfer the JAR file to the target embedded device.

  2. On the target device, run the java launcher to invoke the sample's main class, for example:

    $ deployDir/bin/java -classpath /tmp/JavaFXSamples/Ensemble8.jar ensemble.EnsembleApp
    

    Note the following about this example:

    • On the target, deployDir contains an Oracle Java SE Embedded JRE that includes the controls component or the graphics component.

    • On the target, the PATH environment variable is set so that the Java launcher is found in deployDir/bin/.

    • On the target, the extracted sample applications are in the /tmp/JavaFXSamples/ directory.

    • If the target device uses software rendering, add the following option to the command line:

      -Djavafx.platform=directfb
      

Java applications cannot be terminated from the device's console. Instead, terminate them using a remote shell:

$ pkill java 

Font Setup in Headful Applications

See https://wiki.openjdk.java.net/display/OpenJFX/Font+Setup for information about configuring fonts.

Swing and AWT APIs

JavaFX components included in an Oracle Java SE Embedded JRE have much smaller static footprints than the Swing and AWT libraries, but if you prefer you can use the ARM AWT/Swing configuration of Oracle Java SE Embedded. This configuration supports the Swing and AWT graphics APIs.

Note:

Note that an application can only make calls to the Swing/AWT API or the JavaFX API, not both.

Make sure that the JRE for the target device includes the AWT/Swing configuration. See Configuring the JRE for Swing/AWT Headful Applications.

Close Window

Table of Contents

Oracle Java SE Embedded: Developer's Guide

Expand | Collapse