1 package zirc.base ; 2 3 import java.util.* ; 4 5 import javax.swing.* ; 6 import javax.swing.tree.* ; 7 8 import zirc.xml.* ; 9 10 23 30 31 public class OptionTree extends JTree 32 { 33 38 public OptionTree(XmlConfig _xmlConf) 39 { 40 this.setCellRenderer(new treeRenderer()) ; 41 DefaultMutableTreeNode p0 = new DefaultMutableTreeNode(_xmlConf.getOptionTreeNode0().get(0)) ; 42 43 TreeModel model = new TreeModel(p0) ; 44 this.setModel(model) ; 45 46 ArrayList nodes1 = _xmlConf.getOptionTreeNode1() ; 47 48 for (int i = 0 ; i < nodes1.size() ; i++) 49 { 50 p0.add(new DefaultMutableTreeNode(nodes1.get(i).toString())) ; 51 } 52 53 55 try 56 { 57 jbInit() ; 58 } 59 catch (Exception e) 60 { 61 e.printStackTrace() ; 62 } 63 } 64 65 private void jbInit() throws Exception 66 { 67 this.setToggleClickCount(1) ; 68 } 69 } 70 71 class treeRenderer extends DefaultTreeCellRenderer 73 { 74 public treeRenderer() 75 { 76 this.setOpenIcon(new ImageIcon("fichiers/images/openNode.png")) ; 77 this.setClosedIcon(new ImageIcon("fichiers/images/closeNode.png")) ; 78 this.setLeafIcon(new ImageIcon("fichiers/images/leafNode.png")) ; 79 } 80 } 81 | Popular Tags |