1 9 10 package org.dom4j.samples.swing; 11 12 import org.dom4j.samples.SAXDemo; 13 14 import javax.swing.JFrame ; 15 import javax.swing.JScrollPane ; 16 import javax.swing.JTree ; 17 18 import org.dom4j.Document; 19 import org.dom4j.swing.DocumentTreeModel; 20 21 28 public class JTreeDemo extends SAXDemo { 29 30 public static void main(String [] args) { 31 run(new JTreeDemo(), args); 32 } 33 34 public JTreeDemo() { 35 } 36 37 38 protected void process(Document document) throws Exception { 39 DocumentTreeModel treeModel = new DocumentTreeModel(document); 40 JTree tree = new JTree (treeModel); 41 42 JFrame frame = new JFrame ("JTreeDemo: " + document.getName()); 43 frame.setSize(300, 300); 44 frame.setLocation(100, 100); 45 frame.getContentPane().add(new JScrollPane (tree)); 46 frame.validate(); 47 frame.setVisible(true); 48 } 49 50 } 51 52 90 | Popular Tags |