Example 2: XSL Engine
   Package xu uses an XML file to define menus, toolbar, etc.
   Developer merely defines and 'registers' swing actions; 
     don't have to define or see menu items, buttons, etc.
   XML attributes are accessible to actions when invoked, 
     making all types of configurable processing very easy
   All the work is done by the xu element classes
   Any start-up processing can be invoked if elements registered; 
     xt loads JDBC drivers using the DatabaseDriver element
Previous     Next


[Demo: Display Style view - apply stylesheet to sample database schema]


There are several applications publicly available which use an XML file to define their menus, toolbars and so on - and in that respect, the xu package is nothing new. The main characteristic of xu, however, is its ease of use: in most situations, a developer does not have to deal with the user interface components themselves (menu items, buttons, button groups, etc., and all the fiddly coding associated with them). A developer has to do no more than code the awt actions which he or she needs, and then register them with a 'FrameConfigManager'. Actions supported by standard swing components (such as text areas) can be registered en masse (cut, copy, paste, select all). The remaining work goes into writing the XML document: to associate menu items and toolbar buttons with the actions.

All XML attributes defined in the configuration file for a menu item or button are made available to the swing action at the time it is invoked. With this, the configuration goes much further than merely controlling the appearance of the application. Examples of this used in the xt application are:

Further start-up processing can be invoked as required, provided the element classes required have been registered beforehand. Registering must currently be hard-coded, although it would be straightforward to define an element whose purpose is to register other elements and allow their use immediately. The xt application uses'DatabaseDriver' elements to load JDBC driver classes (although there appears to be a bug in the JDK - because they are not visible after start-up, although manually loading them in exactly the same way later does work).