CookSwing: XML to Java Swing GUI



Support This Project


stats counter


Logo Logo IntelliJ IDEA

CookSwing is a library which builds Java Swing GUI from XML documents. It is under continuously active development, since I make a living by doing Swing GUI :) Unlike many other XUL toolkits, Swing is complete in its capability dealing with Swing and beyond. It is mature and stable. If you like this library, please help spreading the word.


  • All Swing components can be configured.
  • All AWT/Swing LayoutManagers, including GridBagLayout and SpringLayout, can be used.
  • Optional JGoodies Forms layout with CookFormLayout.
  • All Listeners: AWT (ActionListener, etc), Swing (ChangeListener, etc) and Bean (PropertyChangeListener, etc) can be attached to any components that support them.
  • Synchronize menu and button states in XML. This feature was the original motivation to write CookSwing.
  • All Swing Border classes, including complex CompoundBorder can be built.
  • Simple custom tags extensions, with many fully functional tags added using one line statement. In fact, you can view the CookSwing tag library as an extension to CookXml, the XML decoding engine behind CookSwing.
  • Include other XML documents.
  • Support Locale and ResourceBundle. DocumentBuilder can also be changed to your taste.
  • Beyond Swing. Various containers (Vector, LinkedList, Map, Set, and such), String, Integer, Icon, etc can all be configured within CookSwing.


Try the Java Web Start demo for a glimpse of the features offered. As always, if you think something could be simplified, improved, send me an email.

What's New

  1. 1.5.1
    1. Use "ui:" prefix for color and font converters to handle UIManager keys.
    2. The two sub panels of <splitpane> no longer has to specify the left/top/right/bottom location. Default to first one is left/top, second one is right/bottom.
    3. New tag <clientproperty name="name" value="value"/> for setting swing component's client properties. Note that the value can be non-string values.
    4. JRE 1.6 compatibility fix. Mainly because of NumberFormat has been changed.
    5. Minor other internal changes.
    6. Documentation changes for cookxmldoc to generate tagdoc.
  2. 1.5
    1. Updated CookSwing for CookXml 3.0. CookSwing is in the namespace "".
  3. 1.4
    • removed "valuepropertychangelistener" attribute since CookXml 2.5 has a better way of adding a PropertyChangeListener.
    • added "labelfor" attribute for "label" tag. This attribute can do forward id/variable lookup to hook up the appropriate labels and components. Used Swixml's idea. Essentially, you can do
      <label text="Input" displayedmnemonic="VK_I" labelfor="id:inputField"/>
      <textfield id="inputField" columns="20"/>
  4. 1.3.2
    • updated to utilize CookXml 2.4's ClassLoader feature.
  5. 1.3.1
    • changed "listselectionlistener" attribute of <list> tag to add the listener to the JList rather than the ListModel of the JList.
  6. 1.3
    • "table" tag is added to parent after its children has been processed. This change is made to allow table model to be changed and affect the scrollpane.
    • "tableheader" creator now has decodeEngine.setNoAdd (false) added. This avoids an exception thrown for the adder.
    • add "listselectionlistener" attribute to both "table" and "list" tags. It calls table.getSelectionModel ().addListSelectionListener (listener) for table, and similarly for list. Both the actual listener or the variable referenceing the listener can be used.
    • all listeners can be hooked via a variable, or by itself. This allows listeners generated from scripts such as BeanShell to be added to the component without using func.
  7. 1.2.1
    • fixed a bug in DialogCreator that forces dialog tag to specify the parent.
  8. 1.2
    • made to be CookXml 2.0 compatible.
    • additional tags related to formatters of JFormattedTextField.
    • additional tags related to editors of JSpinner.
    • valuepropertychangelistener attribute setter for adding a PropertyChangeListener that only listens to "value" change. Useful for JTextComponent related classes.
  9. 1.1
    • Just a few bug fixes. Mainly the include bug.
    • Moved cookswing under cookxml package.
  10. 1.0
    The initial release.

(c) Copyright 2004-2007 Heng Yuan. All rights reserved.

Valid XHTML 1.0! Valid CSS!