Tutorial for XMLPanelEdit: Java Swing GUI by XML > How to use XML editor
Previous Page Contents Next Page
OOP XMLPanelEdit home page

Contact Us

How to use XML editor

2: How to use 'com.oopreserch.xml.edit.XMLPanelEdit'

In the previous page, I introduced how to write Java Swing GUI in XML. But, writing such an XML by the text editor may be very tedious and error prone.
But don't worry. 'com.oopreserch.xml.edit.XMLPanelEdit' is an easy-to-use XML editor.

Image of XMLPanelEdit
View Full image

It works like following:

Note that the change to the structure of our Java Swing GUI is not written the file system immediately:
  1. By the creation of the new element or the modification of the existing element, the on-memory structure of our Java Swing GUI is updated. The updated structure must be validated.
  2. After the updated structure is validated, it can be written to the XML document on the file system.
To avoid the error, it is desirable to save only the valid XML. This is the reason of this two-phase-update strategy.


2.1: Add the new element, edit/remove the existing element

Image of Tool related with element


To add, edit or remove the GUI component, please select some existing element of the GUI tree. Based on the selected element, the appropriate buttons are activated.
As long as some element in the GUI tree is selected (when the corresponding attribute editor is shown in the lower part of the GUI), we cannot select another one in the tree. To select another element, please close the attribute editor (by clicking 'Close' button at the bottom). Then the currently selected element is de-selected and you can select another one.

Any of is clicked, the dialog for choosing the new component appears:

Image of XMLPanelEdit
View Full image


Based on the selected element, only the appropriate child components are listed on the dialog.


2.2: Edit the attributes of the element

Image of XMLPanelEdit
View Full image


After the new component chosen on the dialog or when the 'Edit component button' is clicked, the attribute editor for the selected element is shown in the lower part of the GUI.
After we modified any of the attributes, the 'Update' button is activated.

Image of XMLPanelEdit
View Full image


2.3: Update and validate the structure

When 'Update' button is clicked, 'Validate button' on the toolbar is activated.

Image of XMLPanelEdit
View Full image


At this point, only the 'on memory' GUI structure is updated. If the GUI structure is valid at this point, please click 'Validate button'. Then, 'View GUI button' and 'Save file button' will be activated. But there may be a case that it is not true. For example, 'ToolBar' must have at least one child on it, so the validation will fail if it has no child yet. Please continue to append, edit or remove the GUI components until the GUI structure become valid.
As long as some element in the GUI tree is selected (when the corresponding attribute editor is shown in the lower part of the GUI), we cannot select another one in the tree. To select another element, please close the attribute editor (by clicking 'Close' button at the bottom). Then the currently selected element is de-selected and you can select another one.


Image of XMLPanelEdit
View Full image


Only after validated, we can save the GUI structure into the local file by clicking 'Save file'. Or, we can pre-view our GUI by clicking 'View GUI button':

Image of XMLPanelEdit
View Full image


2.4: Change the character encoding

Image of XML related Tool


We can change the charset of our editing XML at anytime. Clicking 'Change encoding button' will pop up the dialog for selecting the charset.

Image of XMLPanelEdit
View Full image

Java and all Java-based trademarks and logos are trademarks or registered of Sun Microsystems, Inc. in the United States and other countries.


Previous Page Contents Next Page
OOP XMLPanelEdit home page

Contact Us


ALL CONTENTS COPYRIGHT 2002, Jun Inamori. All rights reserved.
Any questions and comments are welcome to Jun Inamori .