Mercurial > hg > RemoteEditor > REPSessionManager
view rep/SessionViewer.java @ 82:4bb583553a42
*** empty log message ***
author | pin |
---|---|
date | Tue, 11 Dec 2007 14:26:13 +0900 |
parents | 02fa9a68d9a2 |
children | 526ee0354067 |
line wrap: on
line source
package rep; import java.awt.Component; import javax.swing.JFrame; import javax.swing.JTree; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; import javax.swing.tree.DefaultMutableTreeNode; public class SessionViewer implements TreeSelectionListener { /** * */ private static final long serialVersionUID = 1L; DefaultMutableTreeNode nRoot = new DefaultMutableTreeNode("top"); DefaultMutableTreeNode nJapan = new DefaultMutableTreeNode("Session:1"); DefaultMutableTreeNode nUsa = new DefaultMutableTreeNode("Session:2"); DefaultMutableTreeNode nKantoh = new DefaultMutableTreeNode("Editor:1"); DefaultMutableTreeNode nKansai = new DefaultMutableTreeNode("Editor:2"); DefaultMutableTreeNode nTokyo = new DefaultMutableTreeNode("Editor:3"); private JTree tree; SessionViewer() { tree = new JTree(nRoot); tree.setRootVisible(true); tree.addTreeSelectionListener(this); //getContentPane().add(tree); nRoot.add(nJapan); nRoot.add(nUsa); nJapan.add(nKantoh); nJapan.add(nKansai); nUsa.add(nTokyo); //nJapan.remove(0); //setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //setTitle("JTreeTest"); //setSize(200, 150); //setVisible(true); } public void valueChanged(TreeSelectionEvent e) { JTree tree = (JTree)e.getSource(); DefaultMutableTreeNode node = (DefaultMutableTreeNode)tree.getLastSelectedPathComponent(); if (node != null) { System.out.println((String)node.getUserObject()); } } public static void main(String[] args) { new SessionViewer(); } public Component getTree() { // TODO Auto-generated method stub return tree; } public void addSessionTree(int sid) { // TODO Auto-generated method stub nRoot.add(new DefaultMutableTreeNode("Session:"+sid)); } }