JavaFX Swing
JavaFX Swing
Search for questions, people, and topics Ask New Question Sign In
Ad by JetBrains
Level up your code with IntelliJ IDEA.
An IDE built for professional development. Make developing enjoyable!
11 Answers
For most situations, Swing. Swing is extremely mature, and very fast. I’m currently
working on software that is expected to be in use for years if not decades. The software is
graphically intensive. By using Swing I am using code that is extremely robust and likely to
have had almost all the bugs worked out. I can trust it. Also, right now, Swing is available
on more versions of Java than JavaFX.
However, there is a new and expanding situation in which JavaFX should be the choice, and
that is portable mobile device applications. This is when you want to write a Java app for
Android and also have it run on Windows mobile and iOS. Products that allow you to do
this tend to use JavaFX as the GUI (and example is Gluon). There are other ways to write
cross-platform mobile apps in Java (such as j2objc) , but they require that you write the user
interface code separately for each platform.
One of the nice things about the situation with JavaFX and Swing is that you can mix-and-
match - using Swing components in JavaFX, and JavaFX components in Swing. It’s not a
binary choice!
1 of 12 2/1/19, 1:27 AM
Which one is better: JavaFX or Swing? - Quora https://www.quora.com/Which-one-is-better-JavaF...
Is JavaFX dead?
JavaFX, easy.
JavaFX is more like WPF/XAML than it is Swing, and that’s a very good thing.
JavaFX, like Swing doesn’t look like a native toolkit on either Mac or Windows (or
anything else), but you can use JNI to add native components if you like, like so:
2 of 12 2/1/19, 1:27 AM
Which one is better: JavaFX or Swing? - Quora https://www.quora.com/Which-one-is-better-JavaF...
That’s a JavaFX application I wrote, running on the Mac, note how there is a native Mac
popup, and also, I’ve taken over the whole window, so there is no title bar. The rest is
JavaFX, So while it’s not native looking, you can create custom controls, and also use JNI
to make up the difference.
You can build JavaFX UIs with XML (FXML) and with SceneBuilder, a GUI builder, both
combined make for an experience not as good as Visual Studio, but it’s close.
JavaFX is also getting supported on Android and iOS. Now personally, I’m not convinced
the performance is there on the lower end phones, but it’s certainly there on the more
powerful tablets.
JavaFX is the future of Java GUIs, whether we like it or not (I like it), so I’d say an easy
win for JavaFX.
3 of 12 2/1/19, 1:27 AM
Which one is better: JavaFX or Swing? - Quora https://www.quora.com/Which-one-is-better-JavaF...
While I can’t say JavaFX is a better choice than Swing for developing a graphics
application, it seems Oracle thinks that way. JavaFX was developed specifically as a
replacement for Swing.
Swing will remain part of the Java SE specification for the foreseeable future, and therefore
included in the JRE.
I have an upcoming Java project this fall that has a graphics component included and our
plan is to use JavaFX.
Swing it’s very mature and has already a lot of flavors, just look in internet for “Java swing
look and feel”, you’ll find things like Substance or Napkin both great projects.
BUT JavaFX is the replace for all the Swing things, so if you have to make a desktop
project from zero, i recommend you to use JavaFX, if you have to modify a project, you can
combine swing components with JavaFX components as well, you can make a progressive
4 of 12 2/1/19, 1:27 AM
Which one is better: JavaFX or Swing? - Quora https://www.quora.com/Which-one-is-better-JavaF...
I am not telling that One is better than the other, i’m just saying Swing is a deprecated
technology.
All things being equal, probably JavaFX - the API is much more consistent across
components. However, this depends much more on how the code is written rather than what
library is used to write it.
Highly dependent on what you're building. Swing has more components around for it (3rd
party as well as built in) and not all of them have made their way to the newer JavaFX
platform yet, so there may be a certain amount of re-inventing the wheel if you need
something a bit custom. On the other hand, if you want to do transitions / animations / video
stuff then this is orders of magnitude easier in FX.
One other thing to bear in mind is (perhaps) look and feel. If you absolutely must have the
default system look and feel, then JavaFX (at present) can't provide this. Not a big must
have for me (I prefer the default FX look anyway) but I'm aware some policies mandate a
restriction to system styles.
Personally, I see JavaFX as the "up and coming" UI library that's not quite there yet (but
more than usable), and Swing as the borderline-legacy UI library that's fully featured and
supported for the moment, but probably won't be so much in the years to come (and
therefore chances are FX will overtake it at some point.)
5 of 12 2/1/19, 1:27 AM
Which one is better: JavaFX or Swing? - Quora https://www.quora.com/Which-one-is-better-JavaF...
6 of 12 2/1/19, 1:27 AM
Which one is better: JavaFX or Swing? - Quora https://www.quora.com/Which-one-is-better-JavaF...
7 of 12 2/1/19, 1:27 AM
Which one is better: JavaFX or Swing? - Quora https://www.quora.com/Which-one-is-better-JavaF...
8 of 12 2/1/19, 1:27 AM
Which one is better: JavaFX or Swing? - Quora https://www.quora.com/Which-one-is-better-JavaF...
Tutorial Link:
9 of 12 2/1/19, 1:27 AM
Which one is better: JavaFX or Swing? - Quora https://www.quora.com/Which-one-is-better-JavaF...
Depends on what you do. Swing is more mature while JavaFX offers rendering using prism.
It can be packaged as an EXE file along with the runtime. For me and the project I work on
these features are very important. Working with JavaFX, I have run into several issues
which will not be popular on stackoverflow( it’s anyway run by trolls now), so you will
have to do some digging of your own.
Robin Sharma
Answered Oct 6, 2016
JavaFX has new features and is more promoted. Things like Properties concept, support for
CSS and modern touch devices, animations etc.
Oracle has made JavaFX different than swing only conceptually. Otherwise JavaFX is
Swing+new features.
The only difference I am aware of between the two is that JavaFx can be used in web
application while using Swing in the web applications even if not impossible, is not very
easy. Otherwise each one has its own merits and the question is this form cannot be
answered. You could ask “Which one is better for doing X: JavaFx or Swing. Then
depending on X one could answer more precisely.
John Ell, MS in CS, Programming since 1977 or so, in a large variety of languages
Answered Feb 28, 2018 · Author has 81 answers and 16.8k answer views
10 of 12 2/1/19, 1:27 AM
Which one is better: JavaFX or Swing? - Quora https://www.quora.com/Which-one-is-better-JavaF...
I mostly agree with others here but I just have to add an observation: If you want to write a
java application to be used on small-footprint plantforms (for example Raspberry) you
cannot use JavaFX but you can use Swing. The tests I have done has shown that Swing is
fully implemented on the Pi but JavaFX is not.
Related Questions
11 of 12 2/1/19, 1:27 AM