FileDocCategorySizeDatePackage
VSX.javaAPI DocExample3441Thu Oct 24 20:14:26 BST 2002None

VSX

public class VSX extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

    if (args.length != 1) {
      System.err.println("Usage is: java VSX testfile.xml");
      System.exit(1);
    }
    JFrame frame = new JFrame("VSX Test");
    VSX parser = new VSX();
    JTree tree = new JTree(parser.parse(args[0]));
    frame.getContentPane().add(new JScrollPane(tree));
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(300,400);
    frame.setVisible(true);
  
public javax.swing.tree.TreeModelparse(java.lang.String filename)

    SAXParserFactory factory = SAXParserFactory.newInstance();
    XMLTreeHandler handler = new XMLTreeHandler();
    try {
      // Parse the input.
      SAXParser saxParser = factory.newSAXParser();
      saxParser.parse( new File(filename), handler);
    }
    catch (Exception e) {
      System.err.println("File Read Error: " + e);
      e.printStackTrace();
      return new DefaultTreeModel(new DefaultMutableTreeNode("error"));
    }
    return new DefaultTreeModel(handler.getRoot());