How to use a newer version of JavaFX in my IDEA project?

Answered

I'd like to use a newer version of JavaFX in my IDEA project. 

I have been happily using v11 and want to use v16.  I'm particularly interested in getting the ability to detect mouse back & forward clicks which aren't recognized until v12.

I originally downloaded JavaFX SDK v11 from openjfx.io.  And I recently downloaded v16 from there as well.

My %PATH_TO_FX% environment variable is set to "C:\Program Files\Java\javafx-sdk-16" (it used to be set to "C:\Program Files\Java\javafx-sdk-11.0.2".

I used IDEA's New Project > JavaFX project to create my JavaFX projects.

The JavaFX bundled plugin is enabled.

I'm not quite sure how to determine which version of JavaFX is being used in this case.  But based on the behavior of the MouseEvent handler (not recognizing mouse back or forward clicks) I'd conclude its a version before V12.

When I use the following to get the version information it just returns JDK version information, not JavaFX version information.

System.out.println(("JavaFX Version: " + VersionInfo.getVersion()));
System.out.println(("JavaFX Runtime Version: " + VersionInfo.getRuntimeVersion()));

outputs:

JavaFX Version: 8.0.291
JavaFX Runtime Version: 8.0.291-b09

I've tried setting up the JavaFX v16 libraries in the File > Project Structure > Libraries, but that doesn't seem sufficient. 

Comments in this post seemed to suggest that my attempts to define which version of JavaFX is used might be futile.  That post is over 5 years old though, so the particulars are likely a bit dated.

Any help at figuring out how to utilize the latest version of JavaFX with my IDEA projects would be appreciated.

 

Here's the "About" info for my version if IDEA ...

IntelliJ IDEA 2021.1.2 (Community Edition)
Build #IC-211.7442.40, built on May 31, 2021
Runtime version: 11.0.11+9-b1341.57 amd64
VM: Dynamic Code Evolution 64-Bit Server VM by JetBrains s.r.o.
Windows 10 10.0
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 8
Non-Bundled Plugins: org.jetbrains.kotlin (211-1.5.10-release-891-IJ7142.45)
Kotlin: 211-1.5.10-release-891-IJ7142.45

0
2 comments

Please see https://github.com/openjdk/jfx/blob/master/doc-files/release-notes-16.md .

You need JDK 11 or later to use JavaFX 16. It looks like right now JavaFX from Java 8 is used by default.

Change project JDK to 11+ to be able to use JavaFX 16.

See also https://openjfx.io/openjfx-docs/ .

1

Thanks for your prompt and informative reply.  I will pursue that.

0

Please sign in to leave a comment.