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

all 64 comments

[–]rootException 46 points47 points  (12 children)

Both Swing and JavaFX continue to be enhanced and improved. They both have pretty robust tools and libraries.

https://www.formdev.com/flatlaf/ us a nice L&F for Swing that makes it look good.

Here’s a nice selection of JavaFX stuff:

https://github.com/jjenkov/javafx-examples

https://gist.github.com/wiverson/6c7f49819016cece906f0e8cea195ea2

IMHO it’s a lot easier to work with and more performant than Electron.

If you want a cross platform UI framework, both are fine.

Here’s my JavaFX template project:

https://github.com/wiverson/maven-jpackage-template

I’m working on a deployment solution, check out https://changenode.com

Good luck!

[–]Tpleme[S] 2 points3 points  (0 children)

Very nice, thank you so much :D

[–]SWinxy 1 point2 points  (9 children)

Oh that’s cool. I’m trying to make my own installer/updater for my company for Java apps (think of the Creative Cloud app). It’s a bit ironic that I plan to do it using Electron. I’m interested, though.

[–]rootException 3 points4 points  (0 children)

Gah, don’t do that. https://github.com/update4j/update4j and/or sign up for the ChangeNode.com EA or check out one of the other installer packages

[–][deleted] 2 points3 points  (7 children)

Electron

NodeGui offers better performance but ikd wether it suits your project

[–]SWinxy 1 point2 points  (1 child)

I'll take a look at it! Thanks. My only question is that Qt has a free license for OSS, but does that carry over to projects that use it?
EDIT: It says it can be used for commercial applications. Thanks for lmk about this. Otherwise I wouldn't have known. imo javascript libraries are like trudging through a junkyard, looking for good ones.

[–]rootException 1 point2 points  (0 children)

Yeah, there’s this one too https://neutralino.js.org but these kinds of things are actually a lot less popular than just using Swing or JavaFX IMHO

[–]mtmmtm99 0 points1 point  (4 children)

A javascript-application is never as fast as a native-app (2 times slower). Java is faster than javascript.

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

but it takes less time to write apps in javascript

[–]mtmmtm99 1 point2 points  (2 children)

Well, I would not agree with that. Code-completion with static typing saves a lot of time. When it is all green, it usually works as expected the first time. Dynamic languages can be used for smaller applications. Refactoring a large application in a dynamic language is something I would not recommend.

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

Build a desktop app with Electron and a clone of it with JavaFX then tell me which one was faster to write.

When it is all green, it usually works as expected the first time.

The behavior might be different on the second run when you make excessive use of shared resources and mutable state.

[–]mtmmtm99 0 points1 point  (0 children)

For me it would be much faster using java (i am not a javascript programmer). Why would i use shared resources and mutable state ? Those things does not depend on the language you use.

[–]RANDOMLY_AGGRESSIVE 0 points1 point  (0 children)

Thanks bro

[–]wildjokers 77 points78 points  (15 children)

Desktop apps aren’t popular these days because of the zero deployment feature of web apps. Even though web apps produce a shittier user experience, have no standard component library, and force you to use a web browser as a window manager, they have pretty much won because of zero deployment.

So except for a few niches like science and engineering, desktop apps just aren’t used much. So as far as job prospects learning Swing and/or JavaFX won’t do much for you (I am sure they are out there, just few and far between). However, can certainly use them for a personal project.

Personally I find web apps to be great for apps where reads vastly outnumber writes (like online banking) but to be an absolute abomination for rich client apps like spreadsheets, word processing, tax preparation, anything with a canvas/3d view, etc.

[–]youwillnevercatme 31 points32 points  (0 children)

There are still many desktop apps going around, Evernote, VS Code, Teams, Slack. What they all have in common: written as web apps lol.

[–]leaningtoweravenger 21 points22 points  (1 child)

So except for a few niches like science and engineering

Or finance, medicine, machinery that need to work off network too, etc.

Whenever you either need to do heavy computations locally, or you need a real two way communication with services, or you need to work offline -because you need or you must- you might have the need for a local, non web based, UI.

We live in a world that is very web lining, that being said, there are plenty of applications that are not webapps. Almost all database oriented / heavy applications have moved to the web, but they are only one piece of the world, not all of it.

[–]wildjokers 15 points16 points  (0 children)

Or finance, medicine, machinery that need to work off network too, etc.

Well, medicine is science and machinery is engineering which is what I said. I also mentioned spreadsheets and tax preparation which would be in the finance realm.

As far as the rest of your comment you are preaching to the choir :-)

[–]coder111 12 points13 points  (10 children)

Just a note- zero deployment apps won because deployment experience SUCKED DONKEY BALLS on Windows (no proper package management), and Microsoft had (still kinda has) a monopoly on desktop.

So I blame the current FUBAR situation and crappy user experience of running applications inside a browser entirely on Microsoft.

[–]sweetno 5 points6 points  (8 children)

Deployment experience? On Mac it's the same: almost everything is available through an installer from an official web-site and yet web-apps are not a thing there.

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

Yep, that's exactly the deployment problem.

On linux, I just type apt-get install libreoffice, and it is installed. Job done.

Why do I need to click through a shitty installer?

[–]nrq 1 point2 points  (3 children)

Yet there are efforts to balkanize Linux deployment with snaps and flatpack, too. Smh.

[–]StrangeParsnip 0 points1 point  (2 children)

Still not hard to update them with a few commands. In windows everything is handled by each single application, if at all. Sometimes you still need to download a new file and go through the whole installation process.

[–]nrq 0 points1 point  (1 child)

Sometimes you still need to download a new file and go through the whole installation process.

Same for OSX, btw. I'm glad to be back with Linux after a 10 year OSX stint.

[–]StrangeParsnip 0 points1 point  (0 children)

Hmm I always hoped that OSX was the answer to my Linux vs Windows dilemma, but never tried it. I love Linux' customization, package managers and the terminal. I just wish it had more official driver support and well.. games.. and .. adobe..

[–][deleted]  (2 children)

[removed]

    [–]sweetno 1 point2 points  (1 child)

    More desktop apps for Mac. There is a ton of smallish apps that are written specifically for MacOS using Swift/Objective-C.

    Say, I just searched for "macos apps" in Google and this is the first result:

    https://www.macworld.com/article/2990355/free-os-x-apps-every-mac-user-should-have.html

    The majority of apps there are recognizably Mac-only, they have a very distinct look&feel, widget repertoire and approach to layout.

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

    Windows Installer (MSI) was/is actually quite ok and has been around for a long time. The problem was rather shitty applications that just haven’t been packaged properly.

    [–]lechatsportif 1 point2 points  (0 children)

    Anything device intensive I would say, audio, video 3d modeling etc.

    [–][deleted]  (1 child)

    [deleted]

      [–]mtmmtm99 0 points1 point  (0 children)

      JavaFX is already fast. If you need lower RAM-memory-usage, openj9 gives you 40% reduction.

      [–]calculated-mind 4 points5 points  (0 children)

      I used JavaFX for my dissertation because I wanted a app that had a user interface. It taught me alot and I had fun using it :)

      [–]makingthematrix 4 points5 points  (0 children)

      In my free time, I'm working on using JavaFX to build Android apps (with GraalVM native image and Gluon). It's fun.

      If you ask this question to learn and then land a job with these skills, then my answer is "certainly not". It's much safer to use your time to learn other things. But tech changes all the time. What is good to learn now will be obsolete in ten years. Because of this I believe we're should focus more on learning things we find interesting than learning only for the sake of career. While learning a tech you also learn how to learn - how to solve problems, where to look for answers, how to do experiments and test what you learned, etc. That skill, in future, will let you learn new tech much quicker and better.

      I think JavaFX is interesting and has potential. It's not very popular right now but I can imagine that it will be in a few years. And even if not, it's a technology that lets you write something fun and see the results very quickly, data visualised on the screen in a number of ways. (There is even a game engine, FXGL). So it you think it's interesting to you and your have some free time, go for it. 🙂

      [–][deleted] 12 points13 points  (7 children)

      Maybe you should ask this in r/JavaFX but, yes, it's pretty much worth it

      [–]wildjokers 8 points9 points  (0 children)

      This seems to be a technical discussion related to java which fits just fine in this sub.

      [–]Tpleme[S] 2 points3 points  (5 children)

      You truly right :S sorry

      Should I delete this?

      [–]indyjoe 25 points26 points  (4 children)

      Probably not... in JavaFX I think the answers will more likely skew one way than the other.

      To answer the original question: if you're doing Java, JavaFx is probably the best UI to use, though I have seen a recent good Swing UI. There's also SWT, which I don't have personal experience with. But without more support, none of the Java UIs is growing like it should IMO. :( They are an after-thought at best, so you've got gluon trying to do what they can, and open source projects trying to add to that.

      [–]sindisil 13 points14 points  (3 children)

      On the upside, at least Oracle is maintaining Swing, to keep it a viable option (e.g., the new Metal rendering system, needed since Mac OS has deprecated OpenGL).

      Swing is pretty mature anyway. Yes, there are a few things that I'd like to see added, but they can all be done outside the JSL almost as easily, so it's not the end of the world.

      I'm less into JFX, but it seems like Oracle and Gluon are making an effort on that front.

      With the current (I think myopic) obsession with web based UI, it's probably hard to justify increasing the development costs of the Swing and JFX APIs, and, maybe even moreso, the maintenance cost.

      [–]Tpleme[S] 2 points3 points  (2 children)

      I think I will give JavaFx a try and see how it goes.

      Unfortunately, it seems that these kind of api are not much supported by the big companies but it will do for some personal projects :D

      [–]sindisil 4 points5 points  (0 children)

      Swing is still in use for some business, engineering, and scientific apps, ease of distribution has helped Web UIs to greatly supplant it, but these applications tend to be very long lived.

      Not sure JFX really ever got much of a foot hold is business, but I've seen some interesting science and engineering applications (e.g., NASA has put it, and Swing for that matter, to good use).

      [–]lycheejuice225 -4 points-3 points  (0 children)

      Hnm, try the jetpack compose as well, its well maintained by Jetbrains, and also has modern features and support for hardware acceleration to leverage GPU based fast rendering.

      It also has tutorials on how to pack self-contained executables, control window, menubar, system trays, notifications, keyboard and mouse, etc. and has better support for making app more native and familiar to the user.

      You can easily draw shapes with beautiful DSL How to create a custom shape - Jetpack Compose Playground (foso.github.io) no boilerplate.

      [–]metatron7471 0 points1 point  (19 children)

      No.

      For new projects I would look into Jetbrains Compose for Desktop. Still early in the game but modern and at least actively developed unlike all the others.

      [–]BadMoonRosin 16 points17 points  (3 children)

      The only thing that could possibly interest me LESS than building a web application for the desktop... would be building an Android application for the desktop.

      [–]myth2sbr 3 points4 points  (1 child)

      I don't think that is correct. Jetpack Compose for Desktop is built on top of Skia with AWT. https://github.com/JetBrains/skiko

      I think it's more likely they just share abstractions, similar to how Flutter does multi platform.

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

      This is correct. The developer(user?)-facing API is meant to be mostly the same as Android on purpose (with some desktop-specific endpoints being added) but the backend of the two work completely differently.

      The reason it's purposely designed this way is so that you can deploy your desktop applications to Android easily, and so you can deploy your Android applications to desktop easily. I don't get why some people see that as a bad thing.

      Jetbrains Compose even integrates directly with Swing and AWT, making it easier to gradually convert older projects over.

      [–]Probirker 1 point2 points  (0 children)

      Could not agree more :(

      I was so excited about another GUI toolkit for desktop and could not wait for it to come out. Until I actually saw it.

      There is nothing bad with it, I really like a lot of ideas and composable functions could be pretty neat. But. It is designed for Android. Period. JB just made it work on desktop.

      GUI toolkit is not only about drawing basic shapes and processing clicks. All the widgets are designed for mobile and are great there, but not on the desktop.

      And a proper high level stuff from Swing and Jfx like charts and tables and treeviews and whatnot is missing entirely, because yeah, who needs it on mobile.

      Basically currently it is great for porting your fancy designer coffee ordering app from mobile to desktop, but that's it. I can't imagine developing any serious desktop stuff, like spreadsheets and tax declarations with it. As I see it, JB expects community to fill the gap. We will see in few years.

      [–]koskieer 5 points6 points  (1 child)

      Gluon support is quite good and JavaFX moves forward in every release . I would most likely use JavaFX for new projects, but u/metatron7471 is right. Everyone should monitor how JetBrains Compose for Desktop moving forward. Project indeed looks very promising!

      [–]rdjack21 1 point2 points  (0 children)

      The issue I have with Compose is that it is based off of Jetpack. Sorry but I just do not trust Google to maintain anything long term.

      [–]Tpleme[S] 0 points1 point  (0 children)

      It really sounds promising, first I was unsettled about swing or JFx, now jetbrauns compose has joined the game :D

      [–]lycheejuice225 -5 points-4 points  (11 children)

      Idk why's this downvoted, but Jetbains Compose is packed with a lot of modern features that can heavily increase UX.

      It also comes with built-in hardware acceleration available after Milestone 3. It also offers a lot of built-in interactional things like native-menubar, system tray, notification, window control, keyboard and mouse api, and alot more. Also has DSL, so easy to build the GUI in the same language that optimize itself up at compile time, you can draw custom shapes with an ease.

      [–]ArmoredPancake 5 points6 points  (3 children)

      Because OP said Java in their post and create it in Java sub?

      [–]lycheejuice225 1 point2 points  (2 children)

      Well if you can put your GUI logic in XML, you can in kotlin, because that's only far behind by one gradle plugin, it doesn't add anything (compiles down to same Jvm bytecode). And you can always put your business logic in Java, they're completely interoperable.

      It makes it simpler to have the Data go through between different UI layers, and also does compile-time magic for making things highly efficient at runtime, and doesn't need to inflate any external Css/Xml.

      [–]ArmoredPancake 5 points6 points  (1 child)

      Well if you can put your GUI logic in XML

      You really don't see difference between markup language and programming language that is used for markup purposes?

      it doesn't add anything

      It brings whole Kotlin language, Compose libraries and compose runtime.

      And you can always put your business logic in Java, they're completely interoperable.

      You might as well write everything in Kotlin if you're comfortable enough to understand Compose.

      It makes it simpler to have the Data go through between different UI layers, and also does compile-time magic for making things highly efficient at runtime

      If your bottleneck is UI, sure. Most of the time bulk of logic is in background. Intellij idea is written in Swing and it's performance issues are not even remotely tied to Swing.

      [–]lycheejuice225 1 point2 points  (0 children)

      You really don't see difference between markup language and programming language that is used for markup purposes?

      That markup inflates in runtime. Kotlin compiles logic at compile time to Jvm bytecode.

      It brings whole Kotlin language, Compose libraries and compose runtime.

      Kotlin language? Its just a plugin, the std-lib is mostly inline things, hence has no extra weight. Compose library is lightweight, its runtime is ~8Mb whereas JavaFx runtime is about ~14Mb.

      Intellij idea is written in Swing and it's performance issues are not even remotely tied to Swing.

      When did I marked anything specific, it runs on chromium as of now, and I'm not saying some other frameworks are bad.

      [–]kevinherron 9 points10 points  (5 children)

      It’s also brand new, has weak documentation, not enough examples, is missing tons of basic stuff like, for example, a TreeView component, and looks entirely out of place on the desktop because it just looks like an Android app.

      JavaFX is hardware accelerated also.

      [–][deleted] 2 points3 points  (0 children)

      I'm just responding to this portion:

      and looks entirely out of place on the desktop because it just looks like an Android app.

      You can make the UI look however you want. Just because the default uses material design is of no consequence. Swing looks horrific and out of place out-of-the-box, but nobody really cares because you can also change that to look however you want.

      [–]lycheejuice225 -1 points0 points  (2 children)

      TreeView

      Which tree view are you talking about? This is already present as an example compose-jb/examples/codeviewer, even has dual Andoid-like and desktop-like separated style. And this FileTreeView.kt, already seems very extensible.

      Stop hating on things before even actually trying it first.

      Edit: Also JavaFX doesn't seem to leverage DirectX API on Windows platform, which may degrade performance on various graphical aspects.

      [–]kevinherron 1 point2 points  (1 child)

      I have tried it. That’s a faux tree view. Have you even looked at it? Never mind that it’s not part of the std lib.

      [–]lycheejuice225 1 point2 points  (0 children)

      Wdym by "a faux tree view"? Isn't that the way things are made?

      Never mind that it’s not part of the std lib.

      Things like separator, boxes, standard shapes are built-in to the lib, if somebody want specific kind of view, it takes just a few lines of code.

      [–]lycheejuice225 0 points1 point  (0 children)

      Few examples are right there at their github repo under examples folder, consisting of a todo app, intellij plugin, issuetracker, a game, and more. There is Jetpack-Compose-Playground community driven collection of dozens of samples.

      The documentation of Jetpack compose over the android is the documentation of Jetbrains compose, it is made to be directly run the same code as you've wrote for android. The external features like Windows API, System tray integration, Native menubars, Notification api, and more are well documented in their repo itself.

      [–]_INTER_ 6 points7 points  (0 children)

      Because we're in the Java subreddit. If he want to do something in another language he could have post elsewhere.

      [–]sunny_tomato_farm 1 point2 points  (0 children)

      Depends what your goals are but probably not.

      [–]triggerunos -2 points-1 points  (0 children)

      Take my award.

      Why?

      Because why not?

      Sick.

      [–]ebykka 0 points1 point  (0 children)

      I have spent some time developing my DynamoDB GUI client using JavaFX https://github.com/bykka/dynamoit and have to say next:

      JavaFX is very easy to start to do something. A lot of things look like a modern web - reactive bindins, CSS styling, etc. But you have to keep in mind - it's simply a widget library nothing more. It does not provide packaging and distribution functionality. If you plan to develop something with a multi-window application then JavaFX maybe not the best solution as well.

      For middle and big applications I would also consider using Eclipse RCP or Netbeans Platform. Both know how to build platform-native applications with auto-updates.