Vous êtes sur la page 1sur 11

Which one is better: JavaFX or Swing? - Quora https://www.quora.com/Which-one-is-better-JavaF...

Search for questions, people, and topics Ask New Question Sign In

Swing (Java toolkit) JavaFX Java (programming language) Programming Languages

Which one is better: JavaFX or Swing?

Ad by JetBrains
Level up your code with IntelliJ IDEA.
An IDE built for professional development. Make developing enjoyable!

Free trial at jetbrains.com

11 Answers

Steve Zara, Programmer for 40 years.


Answered Oct 6 2016 · Author has 2.9k answers and 951.4k answer views

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...

Ask New Question Sign In

Your feedback is private.

Is this answer still relevant and up to date? Yes No

Related Questions More Answers Below

Why did JavaFX fail?

Should I learn swing or directly learn JavaFX?

Is JavaFX worth learning?

Is JavaFX dead?

Is JavaFX still relevant for a desktop Java application?

 Ask New Question

Garry Taylor, Shipped applications written in JavaFX


Answered Oct 7, 2016 · Author has 16.3k answers and 45.9m answer views

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...

Ask New Question Sign In

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.

28k Views · View 152 Upvoters · Answer requested by Elham Afshar

Your feedback is private.

Is this answer still relevant and up to date? Yes No

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...

Ask New Question Sign In


The must-play city building game of 2019.
Journey through the ages and create a mighty empire in this award-winning game.

Play now at forgeofempires.com

Seymour Jones, Senior Software Engineer (1999-present)


Answered Aug 8, 2018 · Author has 858 answers and 170.6k answer views

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.

So where does Oracle stand on Swing?

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.

I have an upcoming Java project this fall that has a graphics component included and our
plan is to use JavaFX.

2k Views · View 1 Upvoter

Natanael Maldonado, Trust me, i am a cat.


Answered Oct 5, 2016 · Author has 351 answers and 232.4k answer views

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...

Ask New Question Sign In

I am not telling that One is better than the other, i’m just saying Swing is a deprecated
technology.

19.3k Views · View 23 Upvoters · Answer requested by Elham Afshar

Bhavya Shah, persuing Masters in Computer Science


Answered Jul 4, 2017 · Author has 217 answers and 271.7k answer views

Which one will be cleaner and easier to maintain?

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.

Which one will be faster to build from scratch?

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.)

6.1k Views · View 4 Upvoters · Answer requested by Elham Afshar

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...

Ask New Question Sign In


Want to learn Python from scratch and for free?
Comprehensive 22-part course includes lots of coding exercises. Beginner friendly, no
prerequisites!

Start now at commonlounge.com

Badar Shahzad, worked at Java


Answered Nov 24, 2016 · Author has 67 answers and 78.8k answer views

Just in few lines:

Javafx is 100 times better than Swing.

Just view this link jfoenixadmin/JFoenix this is a library for javafx.

Pictures of Jfoenix lib:

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...

Ask New Question Sign In

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...

Ask New Question Sign In

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...

Ask New Question Sign In

For more pictures and information visit above mention link.

Tutorial Link:

17k Views · View 39 Upvoters · Answer requested by Elham Afshar

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...

Ask New Question Sign In

Answered Oct 5, 2016

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.

6.1k Views · View 5 Upvoters · Answer requested by Elham Afshar

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.

5.5k Views · View 5 Upvoters · Answer requested by Elham Afshar

Eric Daklan, Java developer


Answered Oct 5, 2016 · Author has 196 answers and 104.6k answer views

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.

5.3k Views · View 5 Upvoters · Answer requested by Elham Afshar

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...

Ask New Question Sign In


90 Views · Answer requested by Elham Afshar

Normann Aaboe Nielsen, knows Danish


Answered Dec 26, 2017 · Author has 117 answers and 64.9k answer views

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.

2.1k Views · View 2 Upvoters

Related Questions

11 of 12 2/1/19, 1:27 AM

Vous aimerez peut-être aussi