XMLTool.java



import org.xml.sax.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/** XML GUI Tool ver 0.01 */
public class XMLTool extends JFrame implements ActionListener {

  /** control panel */
    private ControlPanel controlP = null;

  /** dom pane */
    private DOMTreePane treeP = null;

  /** parse area */
    private HandlerPanel handP = null;

  /** constructor */
    public XMLTool() {

        controlP = new ControlPanel( this );
        handP = new HandlerPanel();
        getContentPane().setLayout( new BorderLayout() );
        getContentPane().add( controlP, "North" );
        getContentPane().add( handP, "Center" );

        pack();
        show();
    }

  /** event handler */
    public void actionPerformed( ActionEvent evt ) {
        try {
            String name = controlP.getSourceName();
            boolean validFlag = controlP.doValid();
            boolean schemaFlag = controlP.useSchema();

            InputSource source = new InputSource( name );

            handP.clear();
            OptionalParser op
              = new OptionalParser( handP, handP,
                                    validFlag, schemaFlag );
            op.parse( source );

            if( treeP != null ) {
                getContentPane().remove( treeP );
                treeP = null;
            }
            treeP = new DOMTreePane( source );
            getContentPane().add( treeP, "East" );
        }
        catch( Exception e ) {
            System.err.println( e.toString() );
        }
    }

  /** start here */
    public static void main( String[] argv ) {

        XMLTool tool = new XMLTool();
    }
}