5 ms·
I have a long history with Swing and as painful as it is to use sometimes (e.g. "There are Swing developers with low pain tolerances?") it's astonishing how pro
by cashewchoo 6y ago
I have a long history with Swing and as painful as it is to use sometimes (e.g. "There are Swing developers with low pain tolerances?") it's astonishing how productive Swing feels compared to React even so many years later. Maybe I'm just warped but GridBagLayout, while containing a certain base level of frustration, is O(1) for frustration. Whereas CSS are absolutely O(n) or worse. One of the best feelings in the world is replacing a complicated nesting of buggy BorderLayouts et al with one nice (slightly verbose) GridBagLayout that actually works.
In my imaginary company that I own where we all run linux laptops that are managed by puppet or something, I think we might make a strong case for building many internal tools in Swing.
The biggest hurdle I see nowadays to using Swing is all about distribution: both of the jvm and the program. Imo that's really where the web won - certainly not because of its dev productivity. So it's definitely a no-go for your actual software product.... but for internal tools where you have a lot more leverage over the environment, I think it looks extremely attractive.
Regarding JavaFX... Honestly, I really like it. I have a personal project that was originally in Swing and I ported it to JavaFX because HiDPI is in a lot better shape there (though I think Swing has since figured it out?). And it's a lot better in many ways. I love-love-love using SceneBuilder for designing the view layer and the Observable pattern, I think, yields a lot of nice QOL/verbosity-reducing things.
That said, I think it did have a slightly higher O() for frustration than Swing's O(1). And I think the community, as a whole, just understands it less (less prior art etc).
So if someone said "build a usable high-quality GUI asap or you die" to me, I'd go to Swing immediately.
- specialist 6y agoMy buddy worked on a niche volumetric (voxel) renderer for ages. I helped with some of the OpenGL bindings and plumbing. Java Web Start (JNLP) worked great. It just worked. His customers loved him. I've always wondered why something like desktop JNLP didn't happen.
- gorjusborg 6y agoI owned development of a JNLP app around a decade ago. JNLP did a good job of solving the app distribution/update problem, but required that you already had the JRE installed. Not too much different from assuming a browser is installed, but I found it much less likely that a user would take the initiative to install a JRE than a browser. They just don't understand what they are doing or why in the case of the language runtime. That said, it did work very well, in my experience.
- monknomo 6y agoI'll echo this. I owned a jnlp app, and most of the support we had was around walking people through installing a sufficiently correct jre. Not always easy to do that
- nitrogen 6y agoWhen I was developing a Swing app, I ended up just distributing an NSIS installer that would automatically download and run the JRE installer if Java was old or missing, for that reason.
- specialist 6y agoI would have bet money the JNLP installer did this. But I'm probably remembering wrong and will defer to the collective wisdom of the hive.
- monknomo 6y agoI am about 90% sure there was some sort of 3rd party open-source wrapper that would download a jre. But I cannot remember what it might have been called
- coliveira 6y agoWhy apps don't just install a copy of the JRE (I believe it is redistributable).
- monknomo 6y agoWhen you're distributing a real installer with a swing app, including a copy of the JRE is definitely the thing to do. A jnlp app is a file format that defines how to launch a java executable over the internet. It defines the location where the executable is, and what version of java is required. Opening the jnlp to download and launching the app requires an installed JRE, or there is nothing to interpret the jnlp and go get the application. There is, iirc, a utility that will wrap a jnlp file and go get a jre. I forget what it's called, but it makes jnlp apps more like an auto-updating standard app. The benefit of the jnlp approach is if you can guarantee your users have java installed, then they don't need to install your app. Just click a link, then a java app self-downloads, installs and sets up a shortcut on the desktop. And it updates whenever they open it and a new version is detected.
- goatinaboat 6y agoI've always wondered why something like desktop JNLP didn't happen. Wasn’t that Marimba/Castanet? https://www.wired.com/1996/11/es-marimba/ https://www.wired.com/1996/11/es-marimba/
- oezi 6y agoIt failed because,... A.) ...they never figured out a good/unobtrusive update process for the JVM itself. B.)...Sun faltered when they picked up steam. (Remember when IBM threw 1 billion USD at writing Eclipse in Java?)
- cocoa19 6y agoAnd Eclipse was hands down the best tool for Java development... Until it was left to rot, and JetBrains came along.
- manishsharan 6y agoAhh ! Gridbaglayout! I hated it so much ! Then I had to work with CSS and JS and I began to realize the genius of the Gridbaglayout!
- spelunker 6y agoGridBagLayout... haven't heard that one in a while. After dealing with CSS madness for years perhaps I should give it a try again.
- mmm_grayons 6y ago> I think swing has since figured [HiDPI] out I hear Java GUI has supposedly gotten better, but all of the Java GUI apps I see look awful. For instance, try telling that to Ghidra and it's butt-ugly text that shows up super thin on my hidpi display. I like Ghidra, but for a graphical RE tool, Cutter is so much prettier with its QT interface. Of course, r2 is great and works from CLI.
- scns 6y agoTake a look at Bitwig
- spullara 6y agoJetBrains products are all Java GUI apps and people love them. Depends on the team building it more than the technology.
- ptx 6y agoPeople love IntelliJ despite Swing because its other qualities make up for the slightly off-looking Swing font rendering, the glitching Swing layout redrawing and the glitching Swing window focus. Also, the menu bar in IntelliJ was reimplemented from scratch to make it work properly. The Swing menu bar would have been unusable with its broken handling of submenus.
- naikrovek 6y agoBut they're ugly and impossible to use, for some of us. Just awful and horrible UI and flow... I simply do not get the love for IntelliJ anything.
- monknomo 6y agoI am right there with you on gridbaglayout. And tools like WindowBuilder make it so fast to generate basically acceptable guis
- naikrovek 6y ago"basically acceptable" is such a low bar.
- FollowSteph3 6y agoFor distribution check out Install4J
- Rebelgecko 6y agoJavaFX also has much better emoji support IIRC
- jfim 6y agoI'd strongly recommend looking at miglayout [0] if you have to do another UI in Swing (haven't tried it with JFX). It's pretty much the best layout library I've seen, bar none, for developing UIs in Swing. You can think of it of GridBagLayout on steroids, and it even handles things like reordering buttons on a per platform basis (eg. Ok and Cancel on a dialog are in Ok/Cancel order on Windows, Cancel/Ok on Mac). [0] http://miglayout.com http://miglayout.com
- t0astbread 6y agoThe link seems to be broken in some way. The page I'm getting is unrelated to miglayout.