Can anybody recommend a (preferably open-source) framework for decoupling GUI from model in Java desktop applications?
Fundamentally decoupling a GUI model from your core java code is best done with a databinding library. Which is to say you have your pojo business code, you have the GUI component code, and you don't fancy writing a load of logic to sync them up all the time whilst updating the view and implementing the business logic. So don't. Find a mature databinding framework for the GUI widgets you are using and learn that; have it keep the screen controls in sync with your pojo code.
JGoodies and beanbindings are good examples of Swing variants of binding onto an OO model. The core bits of JGoodies are opensource. If you go to /articles on the jgoodies site it has articles on pattern and databinding. Whilst each binding framework has different classes the patterns for writing good clean code are portable between GUI frameworks and bindings frameworks.
If you download the now opensource WindowsBuilderPro tool then it has excellent examples in both Swing and SWT of doing good databindings. The swing jphonebook example uses the beanbindings library. WindowsBuilderPro is a drag and drop GUI builder; you used to have to pay for it as a leading drag and drop GUI builder which works with the leading free GUI libraries. It was bought by google and opensourced so that they could beef up its graphical screen builder support for GWT (the Google web GUI framework).
That GUI builder tool has both excellent sample code and is an excellent opensource tool now. It does the same example of a phonebook in both Swing and SWT GUI libraries to demo its drag-and-drop GUI builder tool power. So it is a great way to compare and contrast Swing to SWT whilst learning databindings.
Java Swing actually makes good use of MVC for just this purpose.
I would strongly suggest you to try the ZK framework. I have not found until today such a srtong framework. In my company we have applied new projects within a few weeks using the latest patterns like MVVM. The style of programming is much like developing a classic 'desktop' app.
PS: I am in no way related to the ZK people. I am just using their framework.
From your reaction to the suggestion that Swing is an MVC framework for desktop apps, I think that you really need some kind of generator framework that will generate the 'model' and 'view' code from higher level specifications. Examples I'm (more or less) familiar with are Eclipse EMF, GEF and related technologies.
Biscotti is a great framework
Related
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?
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 main goals i am targeting:
Great and modern-looking L&F with support for all Swing components
An extensive set of additional components which you won't find in standard Swing
A big set of Utility classes to assist you with writing the code
WebLaF library also suggests a few other advantages and unique features:
It is an open-source project (GPLv3 licensed)
Easy components styling using painters system (specifically with 9-patch files)
Quick and easy customization of the default "Web" style
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 :)
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());
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.
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.
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.
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
Try one of these:
JTattoo
JGoodies
Quaqua
What about Nimbus look and feel? Oracle Link
Also take a look at SO-Question
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
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.
Swing is good (stable, documented, supported until 2026). The problem is that it relies on the LookAndFeel system that provide a very limited number of boilerplate choices. It should be easy to change the appearance of each component individually and then unleash its creativity. Unfortunately it is painful. IMHO frameworks should be built on top of Swing to make it possible instead of creating JavaFX.
Take a look at https://github.com/dotxyteam/ReflectionUI.
Ex GUI: http://javacollection.net/reflectionui/wp-content/uploads/2017/08/general.png
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.
There is a lot of frameworks support testing Java GUI based on Swing but I can't find any open-source framework supporting AWT GUI testing. The framework should support script writing (not mere recording of user actions). Is there such framework or tool?
You likely can use awt.Robot to write yourself such a tool.
Also meanwhile Swing and AWT can much better be mixed than in older times, you should consider to rewrite your UI, or at least do futur development Swing based.
a good open source framework for Java GUI testing is Maveryx.
It has many good point:
It can handle Swing, AWT, Java Web Start (and soon) applets and SWT.
There are no custom script language, you can write your test case in java.
Thera are no GUI MAP dependences, you don't need any "capture and replay", only write your test and go!
It's fully compatible with JUnit through the Maveryx Eclipse plug-in.
Mauro
I am looking for some framework or toolkit (style drag and drop) for creating gui in Java. I need to do quite complex application with dockings, toolbars, tables etc.
Which one would be best?
The Netbeans Platform might be what you are looking for, it is based on Swing, and the Netbeans IDE can be a showcase for it, check http://platform.netbeans.org/
I think the equivalent on SWT is http://www.eclipse.org/platform/
If you're looking for a GUI builder, NetBeans has a decent one. Otherwise, you can just write it yourself in Swing or SWT?
Start reading Swing Architecture and then use Netbeans UI builder and finally complement it with JIDE Software libraries.
JIDE have several libraries, for instance:
JIDE Docking:
JIDE Grids:
And many more. The only inconvenient I see is, you need a good understanding on how does Swing works before using it ( or you can acquire that knowledge in the process )
eclipse rcp, spring rich client, griffon
all of these frameworks are good to avoid writing boiler-plate code all over again (support for docking, window management, dialog management, preferences management).
i must note that complete drag 'n drop is not supported in none of them out of the box, but there are IDE's that help you in building Swing panels, components, ... in a visual editor. both Eclipse IDE and NetBeans IDE have a GUI Builder/visual editor.
my prefered choice is spring rich client because it's easy to get started, it's swing-based, it integrates with docking frameworks, component libraries, ... and it uses spring.
if you need a pluggable architecture then you should take a look at eclipse, or netbeans.
edited: i mean eclipse rcp
I want to know which is the best tool which can be used to make GUI . Currently I'm working on VC++ 6.0 and I can't give a good look(Vista Look) in that.
So can anyone help me which one will be more suitable for GUI .. Java or any other tool(.net WPF) and if you can give the reason then it is very helpful.
Thanks
I would recommend WPF .. It has the new markup language which suits well the UI development, supported by code behind.
Check some examples http://blog.trivadis.com/blogs/manuelmeyer/archive/2008/06/12/cool-wpf-samples.aspx
Java is designed to work well across multiple systems.
.NET underlies Windows.
If you're trying to imitate Vista's look and feel as closely as possible, go with the framework that was written by the same company that also made your operating system.
Any of the above are capable of a good "Vista" look (including VC++). You just need to opt-in to the new visual control styles with a manifest. WPF will have the most options for a "sexy" Windows UI, and won't need the manifest.
You can use WPF for serving your purpose. WPF lets you
edit the opacity of the elements : so that you can create transparency effect as in Vista
create storyboards for your animations
change the look and feel of existing controls using styles, so it can be easy to create Vista style controls
apply bitmap effects such as Outerglow, Dropshadow, etc.
Although WPF is not limited to the above features, but it is the partial list of features for which you can use WPF to achieve your desired effect.
If you do decide to go down the Java route, take a look at the JGoodies libraries. They take a lot of the pain out of writing Swing apps by providing (amongst other things) a much more usable layout manager, a data binding framework, and some some Windows like look & feels.
Take a look at this to see why you don't want to use one of Swing's standard layout managers directly...
Depends on what you mean by "best" tool.
In Java you are most likely looking at Swing to develop your application as far as frameworks go. If you are looking for a complete RCP, you could take a look at the Netbeans Platform or Eclipse RCP. The Netbeans IDE also has a nice GUI editor that can be used for generating Swing GUIs (if you don't mind working with generated code and the Netbeans IDE).
WPF is very nice but has quite a large learning curve.
Swing is a bit chunky.
7 years ago at least Delphi was a really really polished and good way to produce a windows GUI, since then Delphi has moved to be a .net laungage. So I would recommend at least looking into Delphi
The tool decision should follow your requirements.
Do you need a GUI for a stand-alone Application or a client-server architecture? If it's stand-alone, do you need it for a single operating system or you need it portable? If it's client-server, do you want a thin client ('webapplication') or a rich client, if it's a rich client, you want the user to install it or shall it be provided by a webservice?
Do you want to hardcode the GUI or declare it? Do you have some expert knowledge on a certain programming language or a certain framework or do you want to use the project to learn on or the other (or both)?
I think, it's much easier to recommend something when we have some more background information.
From the few things I know I suggest:
Upgrade your visual c++ environment and keep working with the tools and frameworks you already know. Microsoft products should be the best solutions to develop applications for Microsoft operating systems.
I would recommend Flex with Adobe AIR - it's nice! adobe flex
We have a Java server application using a message based communication passing around strongly typed complex POJO messages. Our regular client is a rich-client Flex application that has a very heavy art and UI development process that doesn't lend itself to rapid prototyping.
We are planning on building a Java UI to test server functionality, currently we have been testing our backend Java server using a console based client using basic commands. The reason we need it in Java is because the messages we are passing around are strongly typed complex Java objects (integrating in any other language requires parsing custom JSON which we are building a code generator for Actionscript to ease this pain).
The issue with using the basic console client, is we're developing a new application where state is being tracked across multiple messages, and simple text console output doesn't make sense we need a more complex UI to show results.
What tools are there for rapidly building a rich client Java UI for use by developers to quickly add new UI's to test a Java backend?
Coding Swing and UIs by hand sucks.
I've looked at Eclipse Rich Client Platform and it looks promising but I'm concerned that the learning curve, and the ease of adding a new UI to test server functionality is not going to be easy. Is there like a light-weight Eclipse RCP, I wouldn't be against having a small subset of developers working on the core Eclipse RCP application while day to day work can be done in a simple rapid-prototyping environment that will easily integrate.
Some Java UI technologies I've been looking into (has anyone had experience rapidly prototyping UI's with a low learning curve for server developers).
Spring RichClient
Groovy Swing Builder
Eclipse Rich Client Platform (RCP)
If you prefer Flex;
Try spring with blazeds
Test it with flexunit
or JSF;
simple jsf design connect to managed bean (mix with spring) and managed bean connect to your service layer ....n
Test it with jsfunit.
You can test it selenium also.
or Swing;
Design with Swixml or Thinlet ((these are remind mxml)
P.S: Don't waste your time to design nice ui. You can do it later. Functionality is important than good looking. Later CSS do it for you. I repeat this, by myself :)
Really, if you are going to use Swing, your developers are going to face a learning curve. Groovy SwingBuilder and similar libraries are just DSLs that cut out a lot of boilerplate and repetitive code. SwingBuilder certainly saves time (and is more elegant than pure java), but really the complex part of using Swing is dealing with the underlying framework.
The NetBeans Swing UI builder (Matisse) is really nice if you want drag-and-drop Swing development, but you still have to be pretty familiar with Swing if you want to understand how to hook everything together.