Home Java Java-tips GUI Misc GUI Alternatives

Ask Questions?

View Latest Questions

Advertisement


 
 

GUI Alternatives
Posted on: July 26, 2006 at 12:00 AM
To build a Graphical User Interface (GUI) in Java.

Java Notes

GUI Alternatives

The problems

After a little experience, it isn't difficult to build a Graphical User Interface (GUI) in Java, but it is hard to get something that is easy to write and maintain, and looks good. Many styles of GUI programming simply don't scale well.

Separation of concerns

  • BAD: Mix logic and interface. This is a typical style for small student programs. The code to perform the action of a button is in the button's action listener. This does NOT scale well as programs get bigger.
  • GOOD: Separate GUI from logic. As programs grow larger, it's essential to separate the GUI interface processing from the logic. This is easy to do by putting the interface and logic in separate classes. Some GUI generators below help accomplish this.

Some GUI programming alternatives

  1. Use Drag and Drop GUI editors. Many IDEs (NetBeans, Eclipse (only SWT), JBuilder, ...) have GUI editors and there are also numerous standalone products. They don't always enforce separation of interface and logic, but it's usually easy to do. I've used NetBeans with good results.

    The new NetBeans Matisse project looks very promising.

  2. Alternatives to Swing and AWT. You don't have to use the Java GUI libraries to build your GUI. There are alternatives.
  3. Use Flash or JavaScript+HTML for the GUI. Why should your interface be in Java? You can use existing GUI technologies like Flash or JavaScript+HTML (check out Sun's LiveConnect, which should already be installed with your version of Java) to interact with your Java program. Apparently this sounds better in principle that in practice. I'm not away of many users of this approach.
  4. Describe the GUI in some other language (eg, XML). This approach is described below in the XUL (XML User interface Language) philosophy.

The XUL philosophy

Everyone says that user interfaces should be separated from the logic of a program. One of the most promising approaches is to represent the GUI in a markup language (think HTML forms with a full set of widgets). The Mozilla XUL group (see link below) has been one of the most active in proposals in this area, altho their actual offerings don't seem quite ready for prime time. Some good links to start with follow.

I've tried SwixML and Thinlet, both of which read an XML file to build the GUI at execution time. On small test programs I really liked them. They're not quite mature yet (eg, weak documentation). SwixML has a number of users and a helpful mailing list.

Take a look at XUL and Java. It seems obvious to me for some comments by Karsten Lentzsch of JGoodies for some criteria that might be used in evaluating this not-entirely-obvious technology.

Microsoft announced XAML, an XML description of user interfaces (and much more) for the upcoming Avalon system (see below). It looks like Microsoft may take the lead in this area; and I wouldn't be surprised if their work sets the future direction. Java's Java Desktop Network Components (JNDC) (see www.javadesktop.org/articles/JDNC/index.html, Java Desktop Network Components) shows some philosophical interest in XUL.

XUL based and other GUI generator schemes

I didn't look closely at most of these, but this gives the idea that a lot of people would like to make this work. My goal is to find something that makes simple programs simpler, ie something for student programs. Some of these frameworks may be very good for simplifying large programs, but don't seem simpler for small programs.

SwixML www.swixml.org - I've tried SwixML with mixed feelings. On one hand, it forced a very nice separation of presentation from other concerns, and it worked well. One the other hand, there was a lack of documentation and error reporting that made development very time-consuming. If you put in the time to become an expert, this may be a rewarding approach. Open source.
Thinlet www.thinlet.com - Open source. The author's philosophy is aim it at handheld devices. This is worth a look if you're interested in something small, and not based on Swing. I liked the previous version, but haven't looked at the new version.
JGraphAppKitfreshmeat.net/projects/jgraphappkit/ \ - Interprets XML files to build menus and toolbars. Small footprint. Free for single developers, otherwise must buy site license. I haven't looked at it yet.
Luxor luxor-xul.sourceforge.net - It's very hard to focus on this. It's strange that examples from different authors look completely unrelated in how one uses Luxor. This may be good, but it requires more time that I have to sort out what's happening. Open source.
SwingMLswingml.sourceforge.net - Open source. Looks good, but it isn't obvious how to connect the GUI to a Java application. Seems to be oriented toward Applet server communication. Nice demo. Last update Aug 2003.
CUFcuf.sourceforge.net/ - CUF (Client Utilities and Framework) provides an XML representation of the GUI that will work with either Swing or .NET. Interesting, but where's the documentation? Open-source.
AUIML www.alphaworks.ibm.com/tech/auiml (Abstract User Interface Markup Language Toolkit). Includes an interface builder, and same interface can be used either as Swing or HMTL servlet. Works with the Eclipse Visual Editor.
RIB www.alphaworks.ibm.com/tech/rib - Reflexive User Interface Builder -- Another IBM approach using XML to represent a Swing / SWT user interface.
xmlgui xmlgui.tigris.org - Interesting, but little documentation. Has editor. Defines additional useful widgets. Has been used in real project so probably works ok. Not appropriate for simplifying student programs. Open source.
SpeedGJ www.wsoftware.de/SpeedJG - I'm looking for free student tools. Might be good, but at $70 I'm not going to check it out.
xWidglets xwidglets.secretgate.com - GUI editor produces XML UI representation. Free download includes editor, gui engine, documentation. The web site is in French, but at least some of the screenshots show English menus. It's not clear how this is used as an interface to a Java application (my interest), but an example is given using JavaScript. I haven't tried it.
FormBuilderThe SwingEmpire FormBuilder GUI editor builds on the excellent JGoodies layouts, but it doesn't seem mature yet. I'm not sure.
SMaker www.vienas.ch/smaker/index.html - Looks plausible, but it's not free and the cost isn't on the website.
XUI [1] xui.sourceforge.net - Open source. Seems to be actively worked on. Doesn't appear to make small programs simpler. This is not the same as the XUI project listed below.
XUI [2] geekkit.bcit.ca/xui/ - Not the same as the XUI project above. I haven't really looked at it yet.
XMLTalk sourceforge.net/projects/xmltalk - Target is handhelds. Open source.
KoalaGML koalagml.sourceforge.net - Open source. Inactive?
Ultrid www.ultrid.com - There is active development on this project. My first look at it had left a lot of Java details unexplained, but there's a lot more there now. Supports many layouts including table layout, splash screens, wizards, localization, and much more. Also strong support for various scripting languages. Worth a look. It appears to be free (beta 0.7.5), but without source.

There are related efforts, such as

XAML Microsoft's new XAML technology can be used to specify GUI (and much more) design in XML, and the tags directly map into C# classes and other MS languages. Take a look at this MSDN article - msdn.microsoft.com/msdnmag/issues/04/01/Avalon.
XUL www.xulplanet.com/ - XUL is a spinoff of the Mozilla browser user interface project that has inspired many similar projects. This is somewhat of an umbrella organization for XML interfaces.
XFormswww.w3.org/TR/xforms may define sufficiently enhanced XML forms that can be used for program interfaces, but ...
BML Bean Markup Language www.alphaworks.ibm.com/tech/bml/
JEasy www.jeasy.de - $49
JBeaverwww.ratundtat.com
text2guiwww.tacosoftware.com/products/text2gui Uses resource bundles to store the GUI description in text. Can easily internationalize. Looks interesting. Not free.

GUI Editors

jviderwww.jvider.com - $69
JFormDesignerwww.jformdesigner.com - 129 Euros. Has some very nice features.
JGB Java GUI Builder jgb.sourceforge.net - Open source. Inactive?
LayoutBuilderwww.jdc-software.com - Free 30-day trial, $20
Atris sourceforge.net/projects/atrisframework - Open source.
Foam www.computersinmotion.com $150, 15-day free trial, but it's free to students and educators. Uses it's own layout manager. Take a look at the video. Separates the interface from "model". Apparently cross platform. Looks interesting, but website doesn't have much documentation.
Qt Designerwww.trolltech.com/products/qt/designer.html can produce a .ui file that can be run thru UICompiler (uic.sourceforge.net). I've tried this combination, and was unable to get it working without errors, perhaps because on Windows the only free version of Qt Designer (2.3) is old and didn't play well with UICompiler.

Alternatives to Swing

Altho Swing (or the older AWT) is the standard for a Java GUI, there are alternatives. These alternatives exist because some are smaller and/or faster than the very general, but large and somewhat sluggish Swing library.

SWTStandard Widget Toolkit, www.eclipse.org. This free GUI library from IBM provides an interface to the native system GUI (currently Windows and GNOME). The advantages are a more responsive user experience, and the Eclipse GUI editor for uses SWT, not Swing. The disadvantages are a different API so your programs can't simply be changed from Swing to SWT, and it isn't as portable, at least until versions are available for more systems. It's possible to compile completely native (no virtual machine!) programs for Linux.
SwingWTswingwt.sourceforge.net. This free GUI implementation provides a Swing compatible API, but uses SWT for the implementation. Because it's compatible with Swing, it's easy to try this out.
BambooKitwww.bambookit.com. Light-weight XML-based GUI good for small devices.
Zavalwww.zaval.org. Another light-weight GUI.

Another approach

UIHierarchy tries to capture the hierarchical nature of layouts by providing classes that reflect this nicely. Has links to similar efforts.

Advertisement


DMCA.com