JavaFX and Java Interoperability

Can I utilise the new functionality provided by the new JavaFX APIs directly from Java to the same extent as I would be able to using JavaFX Script?

Are all the underlying JavaFX APIs purely Java or JavaFX Script or a mix?

Asked by: Julia186 | Posted: 21-01-2022

Answer 1

The JavaFX APIs are a mix of JavaFX and Java. The SDK comes with an archive which contains a part of the APIs (only the most basic classes are included, but things like javafx.scene are missing).

Calling JavaFX code from Java is not officially supported in JavaFX 1.x AFAIK. There's a blog entry in the JavaFX blog that shows you how to do anyway it using unsupported APIs, but it's complicated and won't work this way in future versions.

There are two supported ways to use JavaFX from Java. Either you use the Scripting API to invoke JavaFX code, as shown in this article. Or, which is the most elegant solution IMHO, write the API-accessing code using JavaFX, define Java interfaces to interact with your JavaFX code from plain Java, and then implement those interfaces in JavaFX.

Answered by: Jared920 | Posted: 22-02-2022

Answer 2

We were able to use the multi-media components with JavaFX with some success. they are totally unsupported in this manner and subject to change similar to how the com.sun packages are in JavaSE.

We integrated them into a Swing UI and were able to do the MM stuff you could do from FX straight from Java.

Hope they put some of that in the core libraries soon.

Answered by: Brad861 | Posted: 22-02-2022

Answer 3

The scenegraph used in JavaFX is opensource. You can check it here ( While the site hasn't been updated to reflect the final version shipped with JavaFX 1.x, you can still use the jar that comes with the JavaFX SDK and mix scenegraph and swing nodes inside your swing application. However, you'll have some difficulty because there's no official API for this version of scenegraph.

Here's a "hello world" using the scenegraph that comes woth JavaFX 1.0. Remember to include the "Scenario.jar" in your build path.

import java.awt.Color;
import java.awt.Paint;
import java.awt.geom.Point2D;

import javax.swing.JFrame;
import javax.swing.SwingUtilities;

import com.sun.scenario.scenegraph.JSGPanel;
import com.sun.scenario.scenegraph.SGGroup;
import com.sun.scenario.scenegraph.fx.FXText;

public class HelloWorldScenario101 implements Runnable {

     * @param args
    public static void main(String[] args) {
        SwingUtilities.invokeLater(new HelloWorldScenario101());

    public HelloWorldScenario101() {

    public void run() {

        this.frame = new JFrame();
        this.panel = new JSGPanel();
        this.text = new FXText();
        this.paint = new Color(255, 0, 0, 255);

        frame.setTitle("Hello World");
        scene = new SGGroup();
        this.text.setText("Hello World");
        this.text.setLocation(new Point2D.Float(10, 10));


    private JFrame frame;

    private JSGPanel panel;

    private SGGroup scene;

    private FXText text;

    private Paint paint;


Answered by: John289 | Posted: 22-02-2022

Similar questions

Real-time Java interoperability

I am wondering how it's the interoperability between JRE6 and the JVM from rtsj. It seems that I have to use only their implementation (since the code will be interpreted using their JVM), so I cannot use many of the features that Java 6 has to offer. Can it support a GUI? (say for example to modify the parameters of an industrial process). I might be wron...

Java and .Net interoperability

I'm attempting to use the WebI ReportEngine SDK (AKA RENET) to change the Universe that is assigned to a WebIntelligence (WebI) rpeort. Much research led me to the changeDataSource() method (exposed by the Java version of the SDK, AKA REBean). Unfortunately, the changeDataSource() method isn’t available in the .Net version of the WebI ReportEngine SDK (AKA RENET). In fact, there doesn't appear to be a way to do...

Java/Scala (deep) collections interoperability

Could you please share your opinion on what is the most elegant and/or efficient way of converting a java.util.HashMap[ java.lang.String, java.util.ArrayList[ java.util.ArrayList[java.lang.Double] ] ] (all of the objects are from java.util or java.lang) to Map[ String, Array[ Array[Double] ] ] (all of the objects are from scala)

java - JBoss Web Services interoperability with ASP.NET

I have a Web Service deployed on JBoss 4.2.3. The Web Service is created using the EJB3 @WebService annotation. One of the method requires an object which has a java.util.Date property public void createUser(UserDTO dto) throws FancyException{ //-- do some work here } class UserDTO { ..... private Date joined; //-- appropriate setters } I have 2 ...

user interface - Interoperability between Java and Clojure and creation of GUIs

I've been playing around for some time now with Clojure and I simply love the LISP-syntax, it's really beautiful, expressive, simple and yet extremely effective. I've also been toying around with C# for some months and find it's syntax really verbose and quite ugly, but yet it works for me but I'd prefer the LISP-syntax. However; the lack of a GUI-library/designer specifically for Clojure has been getting on my ner...

XML serialization library interoperability between Java and Python

I have been searching for an xml serialization library that can serialize and deserialize an (Java/Python) object into xml and back. I am using XStream right now for Java. If XStream had a python version to deserialize from xml generated by Xstream that would have done it for me. Thrift or such other libraries is not going to work unless they allow the data format to be xml. I am looking for suggestion for any library that...

java - Eclipse - JBoss 4.2.0GA runtime with JRE System Library [JavaSE-1.6] interoperability

Is JBoss 4.2.0GA operational with JavaSE-1.6? I have openjdk installed in Ubuntu. Whenever I am trying to set the Properties of a Dynamic Web Project to JBoss 4.2 Runtime JRE System Library [JavaSE-1.6] The project explorer of Eclipse showing an error beside the project name.

java - Web Services Interoperability

I have few fundamental questions Question#1 With WCF you can expose a service as HTTP/TCP/MSMQ binding Similar to this do we have any equivalent solution in Java platform for exposing service with different bindings Question #2 i have worked on .NET 2.0 ASMX service and consumed the same using .NET client What are interoperability aspects that we need to ...

c# - Java and .NET Streams Interoperability Through IKVM

In my current project I use IKVM to cross-compile several Java libraries that deal with various aspects of XML. These libraries are then integrated with several .NET libraries and my mainline code. Everything works fine, but I suspect that there are several inefficiencies, especially in the area of stream-based data access. Many of the Java libraries can accept streaming SAX classes or other streaming objects such ...

WCF and Java interoperability

What is supported out of the box with a Java Client talking to WCF service version 4.0. What protocols, bindings and security features are not supported (limitations if any).

Still can't find your answer? Check out these amazing Java communities for help...

Java Reddit Community | Java Help Reddit Community | Java Community | Java Discord | Java Programmers (Facebook) | Java developers (Facebook)