CookSwt: XML to SWT GUI



Support This Project


stats counter


Logo Logo IntelliJ IDEA

CookSwt is a library which builds Java SWT GUI from XML documents. The current version is 1.2.


  • All SWT components can be configured. Resources (Image, Font, Color, Cursor) are automatically disposed when widgets using them are disposed. Run the demo on your local machine with "-ea" (enable assertion) for disposal messages.
  • All SWT Layouts. Any complex layouts can be created.
  • All SWT Listeners.
  • Simple custom dialog creations with <xmldialog>.
  • Small things, such as DROP_DOWN ToolItem with DROP_DOWN Menu, adding control to a CoolItem or ToolItem and set the size at the same time, auto-relayout Shell when a CoolBar resizes, and auto-relayout wrapped ToolBar.

The following features are common to CookXml extensions.

  • Simple custom tags extensions.
  • Include other XML documents, or an element within an XML document.
  • Locale and ResourceBundle support.
  • Various containers (Vector, LinkedList, Map, Set, and such), Strings, primitives, Object/primitive arrays, etc can all be configured.

There is one feature missing (comparing to CookSwing), the ability to synchronized menu item and button states. Unfortunately, I just don't see how that is possible for Enabled/Disabled states without telling programmer to re-write their listeners base on a new class. In fact that was what JFace was doing with IAction. Before fully evaluating the possibility of dealing JFace with XML, it is probably not a good idea in introducing a whole new set of things.


Try the Java Web Start demo (Windows only) for a glimpse of the features offered. The demo itself used the CookSwt to generate the GUI. Since SWT requires native library, full permission is necessary.

What's New

  • 1.3
    1. Updated CookSwt for CookXml 3.0. CookSwt is in the namespace "".
  • 1.2.1
    1. Forgot to make glcanvas to inherit canvas tag in 1.2.
  • 1.2
    1. Updated CookSwt for SWT 3.2. The changes are:
      • 1ToolTip
      • ExpandBar and ExpandItem
      • GLCanvas and GLData. GLCanvas is limited to creating a new empty instance. <gldata> needs to be a child of <glcanvas>.
      • Table and Tree added "sortingdirection" setter.
      • Composite added "backgroundmode" setter;
      Let me know if I missed anything.
    2. updated examples and added some missing widget examples.
  • 1.1.1
    1. Fixed ImageConverter bug for 3.1 where ICON_ is the prefix for system images. Thanks to Thorsten Dittmar.
  • 1.1
    1. Updated for CookXml 2.0.
    2. Updated for SWT 3.1. Specifically, <tabletree> and <tabletreeitem> are removed from the tag library. <link>, <spinner>, and <treecolumn> are added.
    3. Additional widget demos in CookSwtDemo.
  • 1.0
    The initial release.

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

Valid XHTML 1.0! Valid CSS!