Skip to content

, ,

XML4SWING live project

October 23, 2010

In the JAVA environment, desktop software is not the must as, for now, the server side is very appreciated. Of course, SUN has created some time ago a brand GUI interface: JAVA FX. But for simple software, I think it is something complex to use. This is why I’ve looked into the SWING interface.

Last time I’ve programmed a desktop application based on Swing was in 2002 with JAVA 1.3. I was young. This time, I’ve looked into Swing because I’ve used MQJExplorer to explore the messages in a IBM MQ-Series queue. And I’ve hacked the code to be able to retrieve my XML messages and some other stuff.

For another application (to transform a SQL result set to a beautiful EXCEL file), I needed to create quickly a graphical interface. An the things have not changed a lot since the last years: you have several products (including Netbeans providing such things) but nothing really simple, creating the graphical part of the source code I can enhance with the functional one in another class. This is why I’ve created XML4SWING.

Currently the product is stored in SourceForge and I’ve created about 80% of what I wanted. Of course, as the project started at the beginning of this month and I developed only during my free time, this is not yet perfect. There is no JDialog support. Same for menus: popup menus are not available yet. But the frames are ready with some features.

The main idea behind this program was to be able to create graphical interfaces very quickly for internal tools, simple software and some other stuff. If you need a strong and beautiful GUI interface, just give a look to other products. If you like to have a XML file as the source of your graphical objects, it is useful to use my program.

Here some of the features (already implemented, not a wish list):

  • For frames, a toolbar (on the right, on the left or on the top as you decide), a menu bar and a status bar are available natively.
  • No layouts: I think the complexity of swing is the mandatory use of layouts quite complicated to understand. XML4SWING uses <table>s for GridBagLayouts. For other parts of the code, the layout is invisible.
  • Mnemonics are enhanced in the text of the buttons/menus/labels. Use the underscore sign before the letter you want underline.
  • The generated code can be tested directly with a provided “main” static class.
  • The objects can be accessed by your application where they are explicitly named (with the “id” attribute).
  • For menus and buttons, you just have to give the method name to use or directly the code into your XML file (for very simple code).
  • The text of the labels, buttons, text fields can be accessed directly through a getter and a setter if you provide the “property” attribute (can be integer or String).
  • The attributes names to provide are based on HTML tags rather than the Swing naming. For example, <textarea id=”myTextArea” rows=”10″ cols=”20″> provide a text area of 10 rows and 10 columns. You can also use <input type=”checkbox” … > for a check box.
  • You can set icons by giving their URL address or their resource path if they can be accessed through the CLASSPATH.
  • The <table> tag creates pretty good layout for dialogs, etc…
  • The <lookandfeel> tag in a menu adds the look and feels available inyour environment and add all the management control when user select one.
  • You can provide your code for window and mouse events (MouseListener and WindowListener already implemented).

Currently, the code is available as a tar download (there is no files available yet but you can obtain a tar file directly from SourceForge at this link). The code includes a example of what you can do with the program: there is a file explorer (a Finder) given as an example: 200 lines of code generated for the interface and 200 lines of code for browsing the drives of your PC (works also on MacIntosh and Linux). I hope to provide more examples soon.

At the web site of the project (, you can see the documentation in the PDF format. The documentation has to be finalized.

Everyone can participate to the project. Have fun.


From → Other

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: