23

I had a Java Desktop Application in which graphical user interface had designed in swing. After we came to know that JavaFX replacing Swing We have replaced graphical user interface with JavaFX.

"6. Is JavaFX replacing Swing as the new client UI library for Java SE? Yes. However, Swing will remain part of the Java SE specification for the foreseeable future, and is included in the JRE. On one hand, Swing is widely used in existing Java desktop applications, but relies on an old architecture, which requires a certain level of expertise and specialization. On the other hand, JavaFX features a set of modern UI controls that can be skinned using standard CSS techniques. While we recommend developers to leverage JavaFX APIs as much as possible when building new applications, it is possible to use Swing and JavaFX within the same application, allowing developers to extend existing Swing applications."

Now we heard that Oracle donate the JavaFX toolkit to the open source community and OpenJDK Community had agreed to take it on.

The JavaFX toolkit evolved from the F3 project at Sun. Initial releases were based around the JavaFX scripting language, however, in 2011 the toolkit was completely rewritten in Java and released by Oracle as JavaFX 2.0. In October 2011 Oracle announced that it would donate the JavaFX toolkit to the open source community and by November 2011 the OpenJDK Community had agreed to take it on.

I do not think so JavaFX is stable. It has no quick support. Document are not enough explanatory. It does not release internal memory when stage is closed. My application is multithreaded application and most of time taken by my application in updating status of each individual thread. Self contained copy of JRE in native bundle does not reliable, we have to replaced it with JRE folder that resides into JDK.

It's really frustrating and I wonder, if JavaFX is fit to develop the Java Desktop application.

0

3 Answers 3

19

Oracle's JavaFX FAQs states that JavaFX is a replacement for Swing:

Is JavaFX replacing Swing as the new client UI library for Java SE?

Yes. However, Swing will remain part of the Java SE specification for the foreseeable future, and therefore included in the JRE. While we recommend developers to leverage JavaFX APIs as much as possible when building new applications, it is possible to extend a Swing application with JavaFX, allowing for a smoother transition.

Source: Oracle JavaFX FAQs (http://www.oracle.com/technetwork/java/javafx/overview/faq-1446554.html#6) [last checked: Feb 2023]

However it is noteworthy that as of Java 11, JavaFX is no longer included in the JDK:

JavaFX is no longer included in the JDK. It is now available as a separate download from openjfx.io

Source: Java 11 release notes(https://www.oracle.com/java/technologies/javase/11-relnote-issues.html) [last checked: Feb 2023]

In contrast, in up to and including Java 19, Swing remains in the JDK, under java.desktop: https://docs.oracle.com/en/java/javase/19/docs/api/java.desktop/module-summary.html [last checked: Feb 2023]

Sign up to request clarification or add additional context in comments.

Comments

9
Is JavaFX complete replacement of Swing? 

I think that not,

  • most of components are halfsized in compare with Swing (price for development ???),

  • implementations in JavaFX8 (accesible with Java8) has one important point Swing JComponents could be accesible from JavaFX containers and JavaFX Components will be accesible in Swing JContainers (implemented in newer JavaFX2.2),

  • then JavaFX will be accesible for development of DeskTop applications

  • still question is if will be possible to add JavaFX TextArea together with Swing JTextArea in one JPanel or vice versa (Panel from xxx.scene.xxx)

  • more (the best infos, roadmap, development...) on FX Experience (notice occasionally is down :-)

Comments

4

tl;dr

Yes, JavaFX is the official replacement for Swing.

  • Swing remains fully supported, but is in maintenance-mode.
  • JavaFX is under continual development, with releases every six months.

JavaFX was successfully open-sourced as OpenJFX. Co-led by Gluon and Oracle. Multiple companies offer support.

JavaFX is stable, and has been used successfully for many desktop apps.

Update as of 2020

JavaFX technology has been going quite well in the ensuing years after this Question was originally posted. Java is regularly released on its 6-month train schedule, and JavaFX releases have arrived at the same pace.

Oracle Corp. has completed the process of making JavaFX open-source, known as OpenJFX. The codebase is now housed as a sub-project on the OpenJDK project. Leadership has been assigned to the Gluon company, with Oracle’s continued support.

The popularity and community seem to be growing. The competitors have fallen away, such as Microsoft Silverlight and Adobe Flash both having died.

Oracle continues to support Swing as a required part of any Java SE implementation, but only in maintenance-mode. JavaFX, in contrast, is under constant active development.

Oracle sells support for JavaFX, as do other vendors such as Gluon and Azul Systems.

Some vendors supplying Java implementations bundle the JavaFX/OpenJFX libraries with their JVMs. These include Azul Systems with their ZuluFX product, and BellSoft with their LibericaFX product.

Though cutting-edge presently, there is work being done to build a native apps for iOS and other platforms using OpenJFX with ahead-of-time compilation using GraalVM.

Delivering a JavaFX desktop app is often done by bundling a JDK inside. This produces a “double-clickable” app. Bundling a JDK is more easily done by modularizing your code with JPMS. By leveraging JPMS, a developer can make use of the jlink and jpackage tooling.

See:


enter image description here


Vaadin

If you were using Swing to build client-server apps, consider using the Vaadin Flow framework to build desktop-style apps delivered as a web app.

You write your app entirely in pure Java. At runtime the users’ state is maintained on the server in the JVM while the user-interface is remotely presented in a web browser using standard Web technologies through automatically generated HTML, CSS, and JavaScript.

Vaadin Flow is open-source and free-of-cost. The Vaadin Ltd company sells training, support, and a few specialty add-ons. One such add-on is Swing Kit for gradually transitioning a Swing app to Vaadin Flow.

19 Comments

If this is so, why is it so difficult to set up an IDE with JavaFX? Particularly with NetBeans which the Oracle examples use and the openjfx.io install instructions which are so out of date?
@Phil In the past, I have found IntelliJ offers good support for JavaFX/OpenJFX, including setting up a new project from scratch from a bundled template.
@Phil Are you reading the documentation at OpenJFX.org?
@Phil Yes indeed, I just started a new Hello World app using IntelliJ 2022.3.1 with Java 19 and OpenJFX 19. Up and running in about one minute. For more info, see my recent Answer on Stack Overflow.
@Phil Agreed. A tip though: IntelliJ can download a JDK from your choice of several vendors. Choose File > Project Structure > Platform Settings > SDKs > + > Download JDK…
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.