Hacker Newsnew | comments | show | ask | jobs | submit login

What is best practice when it comes to Java GUIs?

Would you recommend Java for building cross-platform desktop apps with near native UI performance?

The IntelliJ IDE looks great but most Java desktop apps I've come across just look and feel weird. Not sure why there is such a big difference.




You have probably encountered the occasional Java desktop app, without realising. If you can't easily tell it is Java, the development team have done a good job.

Two of my company's three products are a Java desktop app for Mac, and they look and feel like typical Mac apps.

Best practice? IMO you should spend significant time on the GUI making sure it feels native. Otherwise, Swing is still about as good as it gets for Java GUIs. JavaFX is supposed to be more modern and superior, but lacks the large-scale support and third-party component ecosystem that you find the Swing. Although I'd be mighty pleased to be proved wrong on that one!

-----


>You have probably encountered the occasional Java desktop app, without realising. If you can't easily tell it is Java, the development team have done a good job.

I've never seen any Java desktop app that I cannot easily tell it's Java. With most of those apps, even on i7/16GB/SSD systems, you get laggy behavior with Swing and the GC. And SWT still has the "uncanny valley" look going.

-----


Usually because the said developers are too dumb and do everything on the UI thread.

-----


Yes. And things are a lot better now, I remember using IBM WebSphere UI tools (written in Java) circa 2004-5.

It took several seconds of whited-out buttons and stuck UI for every CPU intensive operation -- all on the same thread. And that was from IBM, and from tools that you paid for a small fortune.

-----


Java as a desktop front-end language is dead. Sorry. JavaFX is a sad attempt at trying to re-live it, and no one outside of enterprise environments that are pure JVM shops are attempting to use it.

-----


Actually, no, we have used it for a decade and continue to do so, because it is a reasonably clean and performant UI framework that gives us great control and pretty decent platform-native look and feel.

-----


I challenge you to do anything that is first-class profession UI/UX experience in Java, and not want to tear your eyes out in the process. Try building something Aperture, Keynote, etc in Java. I don't know what you're building but my guess is it isn't 'beautiful' or innovative UI.

-----


True, but how many of us programmers either want or need to do that? Less than 1% I'll bet. For the rest of us, Swing works just fine, and it's a whole lot better than some of the other UI toolkits out there.

-----


Except basic interfaces can still be done with things like iOS. If you're going to take the time to build a UI framework, it shouldn't specialize in being craptaculuar.

I'd also venture to say a lot more than 1%. Modern world (finally) recognizes that design/experience are core to any product, enterprise or not. That's part of the reason there's a whole new breed of funded enterprise companies out there -- they're taking lessons from the web/apps and applying them to replace old-school solutions. [I'm personally hoping more people recognize this need for developer tools which typically are the worst offenders of all, particularly on the database side.]

Part of having a good framework is what allows apps/applications to excel -- it helps you raise your own bar because the tools are just so much better that nicer UI/UX can be had without being a nightmare in code. That's a win for everyone.

-----


it's just pining for the fjords.

More seriously, as a recent example you will find that what bitcoin.org offers you as the first option for a wallet (multibit) is written in java.

That may not be mainstream, but it's definitely not the classic enterprise java shop.

-----


And it looks like it was written in Java. Compare against any serious iOS app, for example.

I've been writing UI code for years, including in Java, .NET, Android/iOS, web, etc, so I have a pretty decent clue about building complex apps in all of these frameworks. Java just isn't a modern environment, and by being cross-platform you end up with an ugly lower common denominator that doesn't have useful APIs for non-trivial designs. iOS is probably the best framework/api out there and even that has many issues (luckily obj-c's categories help you fill in the holes).

-----


JavaFX is now a default platform (supported by Oracle) for developing desktop apps. It replaced the clumsy Swing and is showing a lot of promise. http://www.oracle.com/technetwork/java/javase/overview/javaf...

-----


How widely is this adopted? FX is one of those tools I'm a little leery of because of the possibility it may be abandoned by Oracle if not enough people use it.

-----


What is the case for desktop apps these days vs web apps? I would love to mess around with JavaFX but really can't come up with a compelling reason to use it.

-----


If you want to interact with local hardware/storage media, native apps are still easier. "Offline" mode can also be the default, at least for systems that have a local data store. Finally, multicore CPUs may be theoretically exploited with web workers, but it's a lot easier to just spin up a native thread in your Java code.

Downsides are all the usual ones, of course: updates don't happen automatically, you may need some sort of licensing/DRM if you want people to pay for your application, and your testing story is a lot more complex. (Plus: look-and-feel on various platforms, reverse engineering is that much easier, etc., etc.)

-----


Offline + sync, and higher performance requirements are my two use-cases for desktop apps.

-----


Have a look at SWT. It's the best way to do Java UIs IMO. I don't know why it isn't more popular. It uses the native UI kits internally, so it feels and is 100% native.

-----


There is more to a native ui (common spacing, font usage, interface patterns) than just swapping out the underlying widgets.

-----


Exactly. Try using SWT to do anything like CoreAnimation on the mac with either similar programming ease or buttery results. There's a reason why one should go native for anything beyond a database viewer.

-----


100% native on Windows maybe (and even there it depends on the Windows version). On the Mac it's like a foreign object.

And that's for the more basic widgets -- more advanced widgets have custom implementation from primitives in SWT, so they are hit and miss with regards to native look and feel.

-----


You might be interested in Nifty: http://nifty-gui.lessvoid.com/

It's hardly any "best practice" or "standard", but it looks like people are managing to ship projects with it. Performance is reasonable; on the inside, it's openGL via lwjgl.

Another option is libGDX: http://libgdx.badlogicgames.com/

Their presentations appear to be oriented largely around games, but the parts could be used for a desktop application just as well. There's a number of mobile games in both the app stores using it.

-----


In theory, the Android runtime environment could be ported to most desktop environments. I have seen Dalvik running on Windows 7. I used to be CTO at a company that developed an Android runtime for WebOS. You might infer they could do the same for similar platforms. Jolla has demonstrated Myriad's similar technology running Android apps in Sailfish. So while there isn't as cleanly defined boundary between app runtime and OS as with JavaFX, which is designed to be cross-platform, in practice it is possible to move the Android runtime across platforms with good results. It should even be possible to put Android apps into realizable windows in desktop environments.

There is a lot to be said for taking an environment with a big following and making it cross-platform vs making a cross-platform environment and hoping for adoption.

-----




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: