6 ms·
Java Swing still lets you make native-looking-and-feeling apps (with some care). I don't know of any new GUI frameworks that let you do the same. I consider thi
by cosmotic 5y ago
Java Swing still lets you make native-looking-and-feeling apps (with some care). I don't know of any new GUI frameworks that let you do the same. I consider this a killer-feature of the framework. It's also very fast, backed by OpenGL and DirectX. It also ships with source code and isn't declarative, so it's trivial to step into as a means to debug why your code isn't working.
- jcranmer 5y agoI will freely admit that Java Swing remains the only GUI toolkit I've used that I actually felt comfortable using to write a GUI, rather than something that feels like having to pull out teeth to get things working in a somewhat coherent manner.
- QuercusMax 5y agoAbsolutely agree, provided you use a layout manager that isn't brain damaged. Anyone remember this video? https://www.youtube.com/watch?v=UuLaxbFKAcc https://www.youtube.com/watch?v=UuLaxbFKAcc - Totally Gridbag
- MaxBarraclough 5y agoI don't do a lot of GUI programming, but I always found the Swing layouting to be very frustrating and counterintuitive. As others have said, JavaFX is really pretty good. People who use JavaFX generally seem to be satisfied, it's not often I see a substantive criticism of it, but unfortunately it seems to be widely regarded as too little too late and doesn't get given a chance. The Ada of the GUI toolkit world.
- bitwize 5y agoYou haven't tried AppKit, WinForms, or WPF.
- datavirtue 5y agoWinforms is dead, as in not cross platform and WPF...the same. WPF is declarative XML as is Xamarin Forms (both slightly different XML oddly). Not fun.
- mike_hearn 5y agoXML is actually pretty good at declaring UI. It's the sort of thing the language was designed for - a UI is a tree of attributed nodes, and that's also what XML gives you.
- thrower123 5y agoWinforms is undead. We'll be writing WinForms applications in the 22nd century.
- jeroenhd 5y agoMicrosoft's refusal to port WinForms is truly the most disappointing part of its cross-platform efforts, in my opinion. They have Mono, they can get it working, they just choose not to. I wouldn't build a production application in WinForms, WPF and friends are much better for that. But, for quick&dirty or even moderately complex tools for experts, VS + WinForms simply has no equal. Some Python-based designers come close, but they definitely suffer when it comes to distribution. With modern dotnet tech, Microsoft could allow us to build a (rather sizable) single, statically linked binary for any architecture, with the impressive performance of the dotnet JIT and native controls. After working on Android designs, I've got to say, XML is fine for UI design. You need previews and visual inspectors to get an accurate idea of what you're doing, but describing what control lives where and what properties it has is a perfectly sensible use case for XML.
- kaba0 5y agoIt wouldn’t make much sense to port Winforms any more, as it is CPU-renderer only. It would be disappointingly slow for anything more complex than, well, forms.
- bigger_cheese 5y agoFor a while I thought GTK was great hope for a good toolkit. I remember about this time period in this article (early 2000's) messing around with Perl/GTK to write simple desktop apps. Unfortunately had issues with new version breaking backwards compatibility etc. which killed it. QT also had similar hype but never took off.
- MaxBarraclough 5y ago> Java Swing still lets you make native-looking-and-feeling apps (with some care). I don't know of any new GUI frameworks that let you do the same. That's the whole raison d'être of the (C++) wxWidgets toolkit. [0] It fully commits to using native GUI widgets, rather than impersonating them. (That is, it wraps various other toolkits.) As others have pointed out, the other major cross-platform toolkits (Qt, GTK) also do a pretty good job. [0] https://wxwidgets.org/ https://wxwidgets.org/
- ravenstine 5y agoDo you mean specifically for Java? The Qt framework widgets look pretty dang native on my Mac.
- speedgoose 5y agoQt applications that try to look native are a bit weird for me. They are like a counterfeit product. I prefer an Electron app with a non native look that looks good.
- scythe 5y agoRacket's GUI library comes pretty close, although the memory consumption needs work: https://news.ycombinator.com/item?id=28512406 https://news.ycombinator.com/item?id=28512406
- jjoonathan 5y ago> native-looking-and-feeling apps Who are you kidding? > (with some care) No. Even if you were to give it more care than required to rewrite the GUI natively in each major platform, you still wouldn't be close. Look, I get it, there are plenty of applications where a bit of clunk in the GUI is beneath other things on the priority list. That's fine. But the number of java devs who think clobbering together a few native widgets means they have constructed a native experience is... disconcertingly high. There's a whole GUI world out there beyond the lowest-common-denominator, and Swing isn't even the best at that. Your priorities might still be perfectly rational. I might even make the same decisions under the same constraints. Just... be aware of what you're trading away
- victor106 5y agohttps://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html https://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/...
- Macha 5y agoSwing's platform look and feel does not get a convincing native experience, as you'll find out the first time you open a JFileChooser on Mac and see a clone of the windows XP file picker with widgets made to look like mac OS widgets circa Snow Leopard.
- cosmotic 5y agoSome of those dialogs are indeed not great and a weak point. There are a few options to get a native picker though.
- shannah78 5y agoThe FileDialog is the only AWT widget I still use regularly. It gives you the native file chooser. Unfortunately it isn't terribly flexible when it comes to, for example, only selecting directories. In those cases, I have been known to use JNI to use the truly native dialog.
- 5y ago
- bitwize 5y agoThe only way to achieve native-looking and feeling apps is to use the native UI toolkit of each platform. There is no such thing as a cross-platform toolkit that doesn't introduce jank and inaccuracy.
- mardifoufs 5y agoInteresting, I'm not aware of any Java app that truly feels or looks native. I guess that there is definitely some selection biais, but do you have any examples of native-like Java Swing apps?
- datavirtue 5y agoIt doesn't really matter. The users don't care and who the hell would want a native looking experience on windows anyway? I haven't tried my UI on a Mac recently but I doubt anyone would notice a difference. I have used Intellij IDEA on Mac recently and I appreciated the custom theme.
- criddell 5y ago> who the hell would want a native looking experience on windows anyway? I would. People who use accessibility tools that work best with native controls would as well.
- cosmotic 5y agoIDEA looked near-native (aside from docking/windowing that doesn't have system L&F anywhere) before they forced users away from system L&F.
- smrtinsert 5y agoSWT apps look native last time I used them.
- adrian_b 5y agoI do not know whether the Java GUIs that I encounter from time to time are made with Swing or with other frameworks. What I know is that since the beginning of Java and until now, on every occasion when I use for the first time some program and I am surprised that its GUI is ugly, slow and impossible to customize, then, without exception, I always discover that the GUI is written in Java. Since around 8 years I use only 4k monitors. While on Windows I have encountered some programs which had problems on high-resolution screens, on Linux I never had any problems, except with all professional programs written in Java, which, unlike the native GUI applications, do not honor any system configurations and they do not seem aware of which is the monitor dpi, to adjust their GUI. Moreover, for some reason the programmers who write such Java programs are almost always morons who do not provide any means for changing the fonts which are used by the GUI. Just a few months ago, I have still encountered some expensive professional programs, which used a Java GUI installer. The Java GUI installer crashed on any computer which used monitors with 10-bit color components. When investigating the problem the conclusion was that it is a well-known Java bug that had not been solved for some years and which causes such Java GUI installers to work only on low-quality monitors with 8-bit color components. So much for the supposed benefit of Java being able to run anywhere.
- leftbit 5y agoYes, that's totally annoying since it really isn't very hard to get right... Swings layout managers are just made to deal with this stuff.