/Users/lyon/j4p/src/j3d/viewer/SceneTreeFrame.java

1    package j3d.viewer; 
2     
3    /* 
4     * 
5     * (c) September 1998 by Mauro Marinilli 
6     * 
7     */ 
8     
9     
10   import javax.media.j3d.VirtualUniverse; 
11   import javax.swing.*; 
12   import javax.swing.event.TreeSelectionEvent; 
13   import javax.swing.event.TreeSelectionListener; 
14   import java.awt.*; 
15   import java.awt.event.WindowAdapter; 
16   import java.awt.event.WindowEvent; 
17    
18   public class SceneTreeFrame { 
19       JLabel statusLabel; 
20    
21       public SceneTreeFrame(VirtualUniverse bg) { 
22    
23           JFrame frame = new JFrame("Scene Tree Viewer"); 
24    
25           frame.addWindowListener(new WindowAdapter() { 
26               public void windowClosing(WindowEvent e) { 
27                   System.exit(0); 
28               } 
29           }); 
30    
31           SceneTreeModel model = new SceneTreeModel(bg); 
32    
33           SceneTreePanel sceneTree = new SceneTreePanel(model); 
34           sceneTree.getTree().addTreeSelectionListener(new TreeListener(sceneTree, statusLabel)); 
35    
36           JScrollPane treeScroller = new JScrollPane(sceneTree); 
37           treeScroller.setMinimumSize(new Dimension(0, 0)); 
38    
39           statusLabel = new JLabel(""); 
40           frame.getContentPane().add(treeScroller); 
41    
42           frame.setSize(400, 300); 
43           frame.show(); 
44       } 
45    
46       protected static class TreeListener implements TreeSelectionListener { 
47           JLabel status; 
48    
49           public TreeListener(Object o, JLabel status) { 
50               this.status = status; 
51           } 
52    
53           public void valueChanged(TreeSelectionEvent e) { 
54    
55   //System.out.println(((Node) e.getPath().getLastPathComponent()).toString() ); 
56           } 
57    
58       }//-treeListener() 
59    
60   } 
61