56

Similar questions to this are asked periodically, but many of these answers are outdated.

I need to build a cross-platform desktop application in Java with a GUI of comparable quality to contemporary desktop apps.

Swing is the default choice, but I have yet to encounter a Swing application that didn't look, at the very least, quite dated and clunky (subjective, I know, but with GUIs it's hard to avoid aesthetic judgements).

I notice that the new Bitcoin client now uses QT with Java bindings, and does have an attractive user interface, but this has the disadvantage that it is no-longer pure Java.

So much of what I find when I search for Swing-related libraries is 5 years old or older, even though the aesthetics of desktop applications have evolved significantly since then.

If you needed to build a Java desktop application from scratch, what would you use for its GUI?

mKorbel
  • 109,525
  • 20
  • 134
  • 319
sanity
  • 35,347
  • 40
  • 135
  • 226
  • I don't think the question will survive but... –  Apr 13 '12 at 02:33
  • 1
    This question is inappropriate here, as it asks for discussion and opinion. The FAQ specifically mentions discussion type questions as being a poor fit for the Q & A format of SO. If you have specific programming questions, please ask them and we'll try to help. Conversational questions don't work well here, as they can't be definitively answered. Thanks. :) – Ken White Apr 13 '12 at 02:35
  • 44
    Ken, I don't agree. Not every question has a black-and-white answer, and if SO is limited to the questions that do have a black-and-white answer, then it will be significantly less valuable. In general I think that people are far too eager to close questions here, given that the harm caused by a false positive (a question that was closed that shouldn't have been) is far greater than that caused by a false negative (a question that should have been closed but wasn't). – sanity Apr 13 '12 at 02:38

10 Answers10

29

I can also offer you a new LaF to look into - WebLaF. I'am currently working on it to bring a lot of UI features and make work with Swing much easier for anyone by just using WebLaF library basic features.

A few examples showing how some of WebLaF components look like: Some of WebLaF components

Some of main goals i am targeting:

  1. Great and modern-looking L&F with support for all Swing components
  2. An extensive set of additional components which you won't find in standard Swing
  3. A big set of Utility classes to assist you with writing the code

WebLaF library also suggests a few other advantages and unique features:

  1. It is an open-source project (GPLv3 licensed)
  2. Easy components styling using painters system (specifically with 9-patch files)
  3. Quick and easy customization of the default "Web" style
  4. Lots of features to accelerate and simplify Swing application interface creation

You can try the demo-app to see if it is modern and simple enough :)

Mikle Garin
  • 10,083
  • 37
  • 59
  • your the best this LAF is great :) – Karim Massi Mar 14 '14 at 17:47
  • Absolutely beautiful piece of work Mikle, you are to be commended. – jewelsea Mar 27 '14 at 05:33
  • +++ top of L&Fs, please to ignore - but have to do something with getPreferredSize (one constant for whole L&F applyied for all JComponents) and gap v.s. alingment for Standard LayoutManagers (sure who cares about) – mKorbel Mar 27 '14 at 09:54
  • @mKorbel didn't really understand what you mean. Preferred size with WebLaF acts the same way as it does without it, WebLaF just provides a few addittional options to configure it. And i didn't do anything about standard layout managers - WebLaF uses almost the same layout style MetalLookAndFeel does with just a few small improvements, as i recall, and doesn't change any layout-related stuff. Though i might be missing something - would really love to know if there are actually any bugs presented :) – Mikle Garin Mar 28 '14 at 08:53
  • interesting info, you are overrode MetalLookAndFeel, maybe to corresponded to my comment about non_proportional painting on the screen, my question is do call doLayout (few small improvements, as i recall, and doesn't change any layout-related stuff), I'll post a comment with printcreen when I'm play with your L&F in next time – mKorbel Mar 28 '14 at 09:08
  • Amazing! And high quality demo too! – Teddy Jun 14 '14 at 10:09
11

Have you looked into JavaFX 2.0? It is designed to interop easily with Swing, and has many modern 'good looking' controls.

Also, as lrAndroid mentions, a Swing app can look like a native app if you set the system look and feel with:

UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
8

Look into changing the Look and Feel of your Java program. This allows you to customize the overall "theme" of your program. Here is information on changing the LAF.

lrAndroid
  • 2,834
  • 18
  • 27
  • 1
    Yes, I'm aware of that - do you have any specific recommendations about good modern LAFs for Swing? – sanity Apr 13 '12 at 02:54
  • I personally prefer the GTK LAF. Here are a couple other nice looking ones: http://dlemmermann.wordpress.com/2011/05/10/the-best-swing-look-feel-bizlaf/. – lrAndroid Apr 13 '12 at 02:56
8

I've had good experiences with FlatLaf.

It's easy to install, it's cross-platform, it has no external dependency, it's open-source (Apache license), it includes dark modes and there are tons of themes.

light

dark

After adding :

UIManager.setLookAndFeel( new FlatLightLaf() );

your app looks like it was written during the last decade, and not during the previous millenium.

It also has one high-contrast theme, for accessibility.

Eric Duminil
  • 52,989
  • 9
  • 71
  • 124
  • 2
    Thanks for the hint. FlatLaf looks very convincing. – MWiesner Jan 22 '22 at 19:09
  • 1
    @MWiesner: You're welcome. It was a pleasant surprise, since Java GUIs tend to come with 90s look otherwise. It's still in development, and 2.0 looks promising. – Eric Duminil Jan 22 '22 at 20:09
5

Modern Javascript frameworks (ExtJS, Dojo, etc...) offer the same widgets richness or more (Excel like grids for instance), a wider variety of L&F and usually fit better with the OS of the user. Users are also very comfortable with their browsers and, hey, "modern stuff" is on the web, and the modern web today is HTML+Javascript.

The overhead of converting an app to "web like" is minimal. An embedded Jetty can remain really small and disk space has become much less of an issue.

There are additional benefits going down this route for the future evolutions of the application.

  • Suddenly, the desktop app becomes a server app, which can be accessed from another desktop. We were able top promote a desktop app to 'portal' in a matter of weeks.
  • Rewriting the app in terms of (Ajax) web services provides an easy transition to creating a full REST (or SOAP...) services stack. The app can then be integrated to other applications, easily monitored externally, etc...
  • Support of other devices (smart phones, tablets,...) becomes much easier, by concentrating on the UI layer only
  • As the app grows, separation of concerns is cleaner; developers working on the UI do not have to mess with low level code.
  • There are a lot of excellent JS/HTML designers and developers that do not program in Java.

EDIT

3 years later this has become extremely easy thanks to Electron

Bruno Grieder
  • 28,128
  • 8
  • 69
  • 101
  • How do you handle launching the web browser in a cross platform way? Can you cite some examples of modern desktop apps using the web browser for their UI? – sanity Apr 29 '12 at 22:02
  • 2
    With Java 6+ `Desktop.getDesktop( ).browse( new URI( uriString ) );` – Bruno Grieder Apr 30 '12 at 06:31
  • 1
    ..which you may associate with a `TrayIcon`. If your app is running in the background, the UI can be 'shown' by clicking on the icon and performing the call above again. – Bruno Grieder Apr 30 '12 at 10:18
  • Modern applications: using the browser for local apps is what is behing Adobe Air and HTML 5 storage (Google ditched its application when HTML5 came along with similar functionalities). – Bruno Grieder Apr 30 '12 at 10:25
  • interesting ideas... By chance do you know of some products which took this approach to desk top apps? – Don Cheadle Apr 14 '15 at 20:57
3

Try one of these:

  1. JTattoo
  2. JGoodies
  3. Quaqua
Crazenezz
  • 3,416
  • 6
  • 31
  • 59
1

What about Nimbus look and feel? Oracle Link Also take a look at SO-Question

Community
  • 1
  • 1
keuleJ
  • 3,418
  • 4
  • 30
  • 51
1

I know this question is old, but if you don't want to use FX and still want to use Swing, then try MacWidgets, i've used it on a couple projects. It's very light, and looks great. Below is an old project i was working on, over time i've perfected using macwidgets and now use it internally in my company.

http://www.digitalhand.net/projects/jdataanalyzer/mainGUI.png

Jesse Hernandez
  • 307
  • 2
  • 15
0

QT is quite extensive but also very big (bloated) and complex. There is also the SWT library being used by open office for instance. SWT uses native UI widgets for buttons, tables etc where as Swing emulates them.

However, the trend is clearly towards writing rich client applications for the browser using HTML and Javascript. Both of these have made huge strides in the past few years.

HTML5 specifically targets rich client applications with features such as better forms and local database to support disconnected scenarios (note that this last feature is not standardized yet but it is implemented by all latest browsers).

Javascript has now powerful libraries with jQuery and its many plugins. There are even languages like Coffeescript which can be used to produce Javascript with a simpler and more powerful syntax.

There's also no need for such apps to connect to an outside server. Small footprint local servers (eg: jetty, node.js, ...) and databases (SQLite, H2,...) can be installed on the client to make a completely self contained application.

Bernard
  • 16,149
  • 12
  • 63
  • 66
  • Can you provide any examples of modern desktop apps that have web-based UIs? I know [Freenet](http://freenetproject.org/) does it, but it's hardly an example of good UI design :-/ – sanity Apr 29 '12 at 21:53
0

Go for Jetpack Compose for Desktop. It's a super modern reactive UI which is nice to work with. It also works the same as it would for Android with very few exceptions. It's Kotlin though instead of Java, but these are both JVM based and it's very easy to make the jump.

Cristan
  • 12,083
  • 7
  • 65
  • 69