Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

XUI: Finally, a Java GUI Framework You Can Love

One of the banes of Java GUI development is in the clean separation of GUI definition and control and business logic. Enter XUI, a new framework for Java that has the ambitious aim of not just solving this problem but of making it easy.


advertisement
here are many Java user interface toolkits. The most common, of course, are AWT and Swing, each of which has its advantages and drawbacks. Swing in particular, while it looks great, can be burdensome to develop and leads to large code footprints. As an example, Figure 1 shows a very simple Swing GUI developed with the excellent Oracle JDeveloper IDE.

Without any code to activate this GUI and respond to events such as the Button Click, Figure 1 already involves 114 lines of code, including the necessary imports. A snippet of this code is shown below, where you can see that four lines of code alone are needed to describe the button. This verbosity isn't the fault of the IDE—it's just the way that AWT and Swing work, and this IDE uses components from these frameworks as appropriate.

button1.setLabel("btnButton"); button1.setBounds(new Rectangle(240, 55, 110, 25)); button1.setForeground(Color.cyan); button1.setBackground(Color.magenta);

With Swing you also have the problem of the application logic and the UI description potentially being munged together. With careful work, these can be separated, but most of the time you will use an IDE, and IDEs generally munge the code together if you use their designers. Building a GUI without using a designer tends to be a lot of work, so you end up being stuck with an application where GUI layout and implementation tend to be merged together. Therefore, if you need to separate UI and implementation, you'll need a source management system and build process even for the simplest of projects, and you'll likely have to sort out a lot of the GUI details by hand.

Figure 1. Swing GUI: This simple Java GUI (shown on the JDeveloper stage), developed with a Swing/AWT-based editor, requires a lot of code.
XUI is an open-source project, available on the artistic license that is intended to make GUI development clearer, cleaner, separated, and well modeled. Perhaps most importantly, it will dramatically reduce the amount of code necessary for Java GUIs—and as any developer can tell you, the less code, the less chance of bugs. XUI may be downloaded from its home page on Sourceforge.

It isn't intended as a replacement for the Swing and AWT frameworks, but instead it is a suite of supporting tools to make coding with these frameworks a lot easier. The best way to understand how it works is by example, so over the course of this article you'll use XUI to build some GUIs and gain an understanding of what it does for you.

Author's Note: The artistic license is one of the lesser-known open source licenses. You can see the full license details at: http://www.opensource.org/licenses/artistic-license.php. It allows you to modify the source any way that you like as long as you don't redistribute the modified versions. Modifications should be folded into the main distribution instead (pending owner's approval of course).




Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap