Is JavaFX complete replacement of Swing?
Asked Answered
B

3

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.

Butene answered 12/3, 2013 at 13:37 Comment(0)
S
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 :-)

Scrabble answered 12/3, 2013 at 13:49 Comment(0)
U
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]

Untimely answered 11/12, 2013 at 12:37 Comment(0)
S
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 :-)

Scrabble answered 12/3, 2013 at 13:49 Comment(0)
S
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.

Sculpt answered 19/7, 2020 at 4:15 Comment(19)
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?Dagmardagna
@Dagmardagna 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.Sculpt
@Dagmardagna Are you reading the documentation at OpenJFX.org?Sculpt
@Dagmardagna 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.Sculpt
@Basil the install and IDE integration directions are at openjfx.io/openjfx-docs/#install-javafx. They refer to modular and non-modular projects which don’t appear in NetBeans. I’ll give IntelliJ a try.Dagmardagna
@Basil Yes IntelliJ works. Of course, you must have the OpenJDK downloaded and copied to the correct hidden folder. You must also disregard most of the IDE integration instructions (the part about the modular projects). It’s also unfortunate that the Oracle JavaFX tutorials use NetBeans. All solvable problems but pretty frustratingDagmardagna
@Dagmardagna Agreed. A tip though: IntelliJ can download a JDK from your choice of several vendors. Choose File > Project Structure > Platform Settings > SDKs > + > Download JDK…Sculpt
Nice chart, but I feel like Gluon needs to be mentioned in here somewhere now (aren't they don't their own JDK build now too?). Possibly multiple times. I believe they do commercial support for JFX specifically also.Clovah
"why is it so difficult to set up an IDE with JavaFX?" Probably because of JPMS - Java modules and splitting JFX out of the JDK made things complicated. IntelliJ does support it fairly well out of the box, though. NetBeans has fallen behind in general (former NB user here). Recommend ignoring the modular junk which just makes things needlessly difficult for little gain. It's also a big help using a JDK with FX built in, such as one of Azul's FX JDKs as mentioned in the chart above.Clovah
@Clovah Reread the second paragraph. The Answer does mention Gluon, with a link to their web site. And the Answer mentions that the company took leadership on the OpenJFX implementation of JavaFX technology, in cooperation with Oracle Corp. Yes, Gluon offers commercial support for JavaFX. No, Gluon does not provide any JDK products, so not included in diagram. At least companies do offer JDK products bundled with OpenJFK libraries: Azul Systems and BellSoft, as mentioned in the Answer with links.Sculpt
@Clovah I do agree that a beginner need not bother with modularizing their code with JPMS when learning JavaFX. But for delivering a “double-clickable” app with a JDK bundled inside, then JPMS modularization is quite important. With JPMS a developer can make use of the jlink and jpackage tooling.Sculpt
No need - IMO JPMS can be treated like OSGI - you probably don't need it, and when you do need it, you'll know! changenode.com/articles/fomo-java-modulesClovah
@Basil Bourque Gotcha on the Gluon note. I was looking at the chart exclusively when I commented. :) That's interesting though, because when I "sdk list java" (using SDKMAN on Linux), I get two options for "Available Java Versions for Linux 64bit", under "Gluon"! I don't know what that is, but it's listed under JDKs. It's also a new listing that only fairly recently showed up. Maybe they are planning something?Clovah
imgur.com/fNoFiTY.png I don't get the version numbering logic though.Clovah
@Clovah I stand corrected. I too see a couple items for Gluon when I run SDKMAN! on my Mac, for Available Java Versions for macOS ARM 64bit. I assume the version numbers 22.1.0.1.r17-gln & 22.1.0.1.r11-gln refer to Java 22, which is weird as I see no version 22 yet appearing on the OpenJDK site. I cannot find any info on the GluonHQ.com web site.Sculpt
Well at least I feel better now about being confused with the versioning if I'm not the only one. Maybe it's based on a custom Android/mobile version? Which would make sense for Gluon to care about. A bunch of other JDKs listed in SDKMAN have similar numbers.Clovah
@Clovah I wonder if the r17 & r11 might mean Java 17 and Java 11. Just a wild guess.Sculpt
Oooh, good catch - maybe!Clovah
I think that's it - GraalVM has r8, r11, r17, r19.Clovah

© 2022 - 2024 — McMap. All rights reserved.