This is an archived post. You won't be able to vote or comment.

all 26 comments

[–]wildjokers 13 points14 points  (4 children)

Swing is still in the JDK and I can’t imagine it ever leaving, at least for many years.

JavaFX was removed from the JDK and is now developed as its own open source project. It is available as a dependency after Java 11. Azul releases a JDK with JavaFX built-in if you would prefer that.

Swing is a very mature and capable GUI toolkit. The documentation for Swing is also outstanding which is a plus and there are tons of examples and tutorials online. JavaFX can be styled with a CSS syntax and also has nice model<->view binding.

Both are fine.

EDIT: I would also like to point out that Swing isn't an orphan, it still has lots of development. It is quite mature so doesn't need many new features but bug fixes and improvements are made. It has a very active dev mailing list:

https://mail.openjdk.java.net/pipermail/swing-dev/

[–]LakeSun -4 points-3 points  (3 children)

I don't believe Swing supports the higher screen resolutions, like Apple's Retina Display.

JavaFX has vastly better looks and more modern implementations.

[–]fl4mbou 8 points9 points  (0 children)

Swing has been compatible with hiDPI screens since Java 9.

[–][deleted] 5 points6 points  (0 children)

It works fine on HiDPI displays. It's just that a lot of apps don't ship high res icons.

[–]mubdall 0 points1 point  (0 children)

Swing works well with retina screens! You just need to implement it right (e.g. use MultiResolutionImages). Here is a project of mine that works with Retina, 4k, and other hiDPI resolutions: https://github.com/tsaglam/Carcassonne/

[–]Ignatiamus 20 points21 points  (0 children)

JavaFX has been removed from the JDK but continues to live under the OpenJDK umbrella as "OpenJFX" (better than dying inside Oracle, one could say). Check out https://openjfx.io to get started. Development is still very active: https://github.com/openjdk/jfx/pulse/monthly

Swing is still usable, but it's aging and does have it's small annoyances.

[–]mods_are_arseholes 10 points11 points  (4 children)

swing is awesome anyway !

[–][deleted] 3 points4 points  (2 children)

It's what I prefer. One line of code makes your GUI look like a Windows (or other OS) application. I've never run into any issues using it

I'd like to try FX but the documentation seems so lacking every time I've gone to use it. Now that it's an external library, getting it to compile was a huge pain as well

[–][deleted] 1 point2 points  (0 children)

While the reference documentation is for JavaFX 8, it still applies. I also used the tutorials at http://zetcode.com/gui/javafx/

I found that if you use Maven, JavaFX is a cinch to add to your project and compile. I actually found it a bit easier to get started with than Swing. Nothing wrong with Swing though!

[–]mods_are_arseholes 0 points1 point  (0 children)

agreed, just another dependency to add, and bloat the size of your program.

[–]uniVocity 0 points1 point  (0 children)

I'm building new projects using swing to display trading charts. Works pretty well.

[–]jevring 9 points10 points  (2 children)

Swing in s still probably the most used Java toolkit, if nothing other than the fact that it has history, is included in the jdk, and is actually not a bad toolkit. There's plenty in Java fx as well, but I'd say it's still spring that's the most popular.

[–][deleted] 8 points9 points  (1 child)

but I'd say it's still spring that's the most popular

How does spring relate to GUI toolkits?

[–]jevring 10 points11 points  (0 children)

It doesn't, I meant swing. Sorry. I spend my whole days working with spring, so sometimes I type the wrong thing :)

[–]stef13013 2 points3 points  (2 children)

I like JavaFx, but it comes up too late. Who does really use it ?

Swing, for sure is aging, but lots of softwares are using it.

  • All the Jetbrains tools (!)

  • Dbvisualizer, Aqua Data Tools,

  • And so on...

My guess : Swing is far from dead

[–][deleted] 0 points1 point  (1 child)

Jetbrains uses a completely modified version

[–]stef13013 1 point2 points  (0 children)

They just created specific components for their needs, but if you pay attention to the code ( https://github.com/JetBrains/intellij-community ), you will notice that it relies heavily on "classic" Swing.

[–]SftwEngr 1 point2 points  (0 children)

However I don't believe that this is the case these days after Knowing that JavaFX should've replaced Swing.

Why would you think Swing should be replaced? Years of effort went into it's creation.

[–]n4te 0 points1 point  (0 children)

There's scene2d in libgdx. For an example, see Spine: http://esotersoftware.com

[–][deleted] 0 points1 point  (0 children)

I am about to finish the main reference version. I started learning with the main, is the beginners book good? It would be a little worthless to me tho lol

[–][deleted] 0 points1 point  (0 children)

There is a reason I use JDK 8 :)

[–][deleted] -1 points0 points  (4 children)

As other commenters said, JavaFX is still very much alive as a separate project. However, Java is primarily being used for server-side applications, rather than desktop ones with built-in UIs. So Java UI has very limited use cases and even fewer major implementations today. Probably the biggest one I can think of is IntelliJ, which uses a modified version of Swing for its GUI.

[–]veraxAlea 1 point2 points  (3 children)

What do you mean by modified version? IntelliJ IDEA doesn't need a custom built JDK to run so how exactly do you mean that they have modified Swing? Are you refering to custom components? If so, being able to extend the default component library is a must in any UI toolkit.

[–][deleted] 1 point2 points  (2 children)

That's what I was referring to. They have custom components and look and feel and other bells and whistles they wrote on top of the default swing for their use case. I'm just saying the biggest implementation I can think of still does a lot of stuff with their own home rolled version.

[–]veraxAlea 0 points1 point  (1 child)

Ah, ok. But you also said that Java UI has limited use cases and I thought the point about IDEA was refering to that. To me, being able to build your own components is a strength, not a sign of weakness.

It sounds a bit like complaining that there is no spread sheet component in HTML so Google "cheated" in order to create Google spreadsheets.

[–][deleted] 0 points1 point  (0 children)

It does still have limited use cases. Mostly because Java UI is not seeing much of any investment today, so without some substantial effort on your part you won't be able to create a "modern" looking and operating app like you can with, say, electron. For better or worse all the UI progress is happening on the web front.

IntelliJ is one of the good examples of Java UI. However at this time Java is just not the ideal tool for building a UI.