This document provides the instructions for using
SwiXML to split the GUI. The end result should be 3 files. These files are
- an execution class
- a GUI XML file, and
- an ActionListener? class.
Execution
This class holds only methods for non-GUI execution. These methods should be the ones in the original class which do are not GUI related.
XML
This file holds the design of the GUI. Some things that this XML file needs to specify include
- ActionCommand? attributes in button and menu item nodes
ActionListener
This class listens for events on the GUI, interprets them, and calls the appropriate methods in the execution class. Conversely, this class is responsible for updating the GUI when necessary. For the sake of transparency, this class should maintain the same name as the original (unsplit) class.
Some things that class needs to specify include
- import the javax.swing.*, javax.awt.event.*, and org.swixml.SwingEngine packages
- implement the java.awt.event.ActionListener class. This includes the definition of a method actionPerformed (ActionEvent? ae) which calls methods in the execution class dependent upon ae.getActionCommand()
- hold a reference to the SwingEngine (which we will refer to as swix)
- hold references to all the GUI items defined in the XML file. The XML file simply configures them. This class declares them, and should declare them public
- have a default constructor which should have the following commands
- swix = new SwingEngine(this);
- swix.render(xml);
- swix.getRootComponent().setVisible()
- Furthermore, all GUI elements should register this ActionListener class by calling addActionListener(actionListener)
--
MichaelJPan - 18 Apr 2005