KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > zirc > base > OptionTree


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 //zIrc, irc client.
11
// Copyright (C) 2004 CoolBytes(Stephane claret, Andre Aymon, Alban Zumofen) coolbytes@hotmail.com
12
//
13
// This program is free software; you can redistribute it and/or
14
// modify it under the terms of the GNU General Public License
15
// as published by the Free Software Foundation; either version 2
16
// of the License, or (at your option) any later version.
17
//
18
// This program is distributed in the hope that it will be useful,
19
// but WITHOUT ANY WARRANTY; without even the implied warranty of
20
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
// GNU General Public License for more details.
22

23 /**
24  * <p>Title: OptionTree</p>
25  * <p>Description: le Jtree des options</p>
26  * <p>Copyright: Copyright (c) 2004</p>
27  * <p>Company: CoolBytes(Stephane claret, Andre Aymon, Alban Zumofen) coolbytes@hotmail.com</p>
28  * @version 1.0
29  */

30
31 public class OptionTree extends JTree
32 {
33   /**
34    * optionTree
35    * . Tout est actuellement fait ici, c'est a dire l'ajout de child aninsi que
36    * leur nom.
37    */

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     //construction du tree
54

55     try
56     {
57       jbInit() ;
58     }
59     catch (Exception JavaDoc e)
60     {
61       e.printStackTrace() ;
62     }
63   }
64
65   private void jbInit() throws Exception JavaDoc
66   {
67     this.setToggleClickCount(1) ;
68   }
69 }
70
71 //a faire pour changer les icones du tree
72
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