Servoy 7.2 adds a new bean that supports integrating JavaFX user interface into Servoy. Currently the bean only works in Smart Client (Web Client will just display a dummy label). The bean needs Java 7 to run (both for developer and smart client) as since update 6 release JavaFX is bundled in Java install. In order to enable JavaFX support in jnlp (for Servoy Smart client), setting "servoy.client.javafx" must be set to true from admin page (default is false). If JavaFX is not enabled for Servoy Smart Client the bean will not work. The bean is actually a wrapper around JFXPanel component from JavaFX that is used to integrate JavaFX content into Swing. Along with its inherited methods the bean also has a javascript method: isJavaFXAvailable to determine if JavaFX install is available.
A small Hello World example of the bean:
...
title | Hello World example |
---|---|
borderStyle | solid |
...
offers integration with JavaFX in the Smart Client, a new UI Toolkit for the Java platform.
The integration comes in the form of a low level JFXPanel bean, to which JavaFX UI components can be added through code. The API of the bean is inherited directly from JavaFX's JFXPanel class. A convenient .isJavaFXAvailable() method is added to check whether JavaFX is available or not.
Detailed information on the integration of JavaFX through the JFXPanel into Java Swing applications (which the Servoy Smart Client is), can be found in the JavaFX for Swing Developers tutorial of Oracle.
The most important thing to take into account when integrating JavaFX is that all interactions with the JavaFX components need to take place on the JavaFX User thread, while all interactions with the Servoy scripting layer need to place on Swing's Event Dispatch Thread (EDT). This means that working with JavaFX in Servoy solutions requires knowledge of Java and requires inline Java code.
Requirements
Notes
A small "Hello World" example using the bean:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
if (elements.myfxpanel.isJavaFXAvailable()) { var jsRunnable = { run: function () { var text = new Packages.javafx.scene.text.Text("Hello World"); text.setFont(new Packages.javafx.scene.text.Font(24)); var pane = new Packages.javafx.scene.layout.BorderPane(); pane.setCenter(text); var scene = new Packages.javafx.scene.Scene(pane); elements.myfxpanel.setScene(scene); } } var runnable = new Packages.java.lang.Runnable(jsRunnable); Packages.com.sun.javafx.application.PlatformImpl.runLater(runnable); } |