Tutorial for XMLPanelEdit: Java Swing GUI by XML > Overview
Previous Page Contents Next Page
OOP XMLPanelEdit home page

Contact Us

Overview

Java Swing GUI can be represented in XML!

OOP XMLPanelEdit depends on the simple fact. That is:

Java Swing GUI has the nested structure, i.e. the 'container' component has other 'atomic' level components as its child components. Such a 'container' component knows how to place its child components in it. And each component has a set of the attributes, such as the size, the alignment, the font, the background color and so on. As you know, XML is the good solution to represent the parent-child relationship along with the attributes of each component. Please look at the DTD for this purpose will look like this:
<!ENTITY % panel.mdl
        "layout?,size?,border?,toolbar?,panel.child*">

<!ELEMENT panel (%panel.mdl;)>
<!ATTLIST panel
          %opaque.att;
	  %panel.name.att;
	  %alignmentX.att;
	  %alignmentY.att;
          %label.text.att;
	  %label.image.att;
	  %layout.border.constraint.att;
	  %access.name.att;
	  %access.descript.att;
	  %color.fg.att;
	  %color.bg.att;>

Based on this DTD, Java Swing GUI can be written in XML like this:
   <panel opaque="false">
      <layout>
         <layout.border/>
      </layout>
      <size>
         <preferred>
            <dimension dimensionX="500" dimensionY="300"/>
         </preferred>
         <max>
            <dimension dimensionX="500" dimensionY="300"/>
         </max>
         <min>
         <dimension dimensionX="500" dimensionY="300"/>
         </min>
      </size>
      <border border="RAISED">
         <insets insets.bottom="10"
            insets.left="10"
            insets.right="10"
            insets.top="10"/>
      </border>
      <toolbar opaque="false"
         toolbar.direction="horizontal"
         toolbar.float="false"
         toolbar.layout.border.constraint="NORTH">
            <insets insets.bottom="5"
               insets.left="5"
               insets.right="5"
               insets.top="5"/>
                  <toolbar.child>
                     <component
                        class.name="javax.swing.JLabel"
                        editable="false"
                        label.text="Select!"
                        opaque="false"
                        value.name="label"
                        wordwrap="false"/>
                  </toolbar.child>
   .....

The full DTD is available at the link below:
Once the appearance of Java Swing GUI can be written in XML, our source code will be free from: As a result, our source code can concentrate on the function of each Java component. Moreover, we can modify our GUI without touching any lines of the source code. This ensures the integrity of our source code.

To make it possible, OOP-Reserch developed OOP XMLPanelEdit (XMLPanelEdit for short). XMLPanelEdit consists of:

About XMLPanelEdit

With XMLPanelEdit, all we have to do is:

  1. To write Java Swing GUI in XML
  2. To define the class which generates Java Swing GUI from the above XML

The first step can be done by: This class is the XML editor, by which we can pre-view our Swing GUI.

Image of XMLPanelEdit
View Full image


The second step can be done by one of the following classes: In the subsequent sections, I'll describe:

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 .