Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libUIComponent / src-test-ui / org / gvsig / gui / beans / treelist / TestTreeList.java @ 11625

History | View | Annotate | Download (1.8 KB)

1
package org.gvsig.gui.beans.treelist;
2

    
3
import javax.swing.JFrame;
4
import javax.swing.UIManager;
5

    
6
import org.gvsig.gui.beans.table.exceptions.NotInitializeException;
7
import org.gvsig.gui.beans.treelist.event.TreeListChangeEvent;
8
import org.gvsig.gui.beans.treelist.listeners.TreeListChangeListener;
9

    
10
public class TestTreeList implements TreeListChangeListener {
11
        private int                                         w = 200, h = 380;
12
        private JFrame                                         frame = new JFrame();
13
        private TreeListContainer                tlist;
14
        
15
        public TestTreeList() throws NotInitializeException{
16
                tlist = new TreeListContainer();
17
        
18
                tlist.addClass("uno", 0);
19
                tlist.addClass("dos", 1);
20
                tlist.addClass("tres", 2);
21
                tlist.addClass("cuatro", 3);
22
                tlist.addEntry("uno-uno","uno","");
23
                tlist.addEntry("uno-dos","uno","");
24
                tlist.addEntry("uno-tres","uno","");
25
                tlist.addEntry("tres-uno","tres","");
26
                tlist.addEntry("tres-dos","tres","");
27
                tlist.addEntry("cuatro-uno","cuatro","");
28
                tlist.addEntry("cuatro-dos","cuatro","");
29
                tlist.addEntry("cuatro-tres","cuatro","");
30
                tlist.addEntry("cuatro-cuatro","cuatro","");
31
                tlist.addEntry("cuatro-cinco","cuatro","");
32
                tlist.addEntry("cuatro-seis","cuatro","");
33
                
34
                tlist.getTree().expandRow(0);
35
                tlist.addChangeSelectionListener(this);
36
                
37
                frame.getContentPane().add(tlist);
38
                frame.setSize(w, h);
39
                frame.setVisible(true);
40
                frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
41
        }
42

    
43
        public static void main(String[] args) {
44
                try {
45
                        UIManager.setLookAndFeel("com.jgoodies.looks.plastic.PlasticXPLookAndFeel");
46
                } catch (Exception e) {
47
                        System.err.println("No se puede cambiar al LookAndFeel");
48
                }
49
                try {
50
                        new TestTreeList();
51
                } catch (NotInitializeException ex) {
52
                        System.out.println("Tabla no inicializado");
53
                }
54
        }
55

    
56
        public void actionChangeSelection(TreeListChangeEvent e) {
57
                System.out.println(e.getItem());
58
        }
59
}