public GAGenerationTreePanel(GAObjectMonitor monitor, String parentNodeTitle) { super(); selectedChildrenPaths = new Vector(); generationNumber = 1; saveNumber = 0; generations = new DefaultMutableTreeNode(parentNodeTitle); gaMonitor = monitor; setLayout(new BorderLayout()); tree = new JTree(generations); tree.setShowsRootHandles(true); tree.setRootVisible(true); tree.putClientProperty("JTree.lineStyle", "Angled"); // Add Action Listeners MyTreeSelectionListener listener = new MyTreeSelectionListener(monitor.getSelectionInfoPanel()); MyTreeClickListener mlistener = new MyTreeClickListener(); tree.addTreeSelectionListener(listener); tree.addMouseListener(mlistener); // Add Scroll Plane scrollPane = new JScrollPane(tree); add(scrollPane, BorderLayout.CENTER); // Add Menu Bar Functionality createMenuBar(); add(menuBar, BorderLayout.NORTH); }
public ReplicatedTreeView(ReplicatedTree tree, Object title) throws Exception { this.tree = tree; tree.addReplicatedTreeListener(this); addNotify(); setTitle("ReplicatedTreeDemo: mbr=" + title); tree_model = new DefaultTreeModel(root); jtree = new JTree(tree_model); jtree.setDoubleBuffered(true); jtree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); JScrollPane scroll_pane = new JScrollPane(jtree); populateTree(); getContentPane().add(scroll_pane, BorderLayout.CENTER); addWindowListener(this); table_model.setColumnIdentifiers(new String[] {"Name", "Value"}); table_model.addTableModelListener(this); setTableColumnWidths(); tablePanel = new JPanel(); tablePanel.setLayout(new BorderLayout()); tablePanel.add(table.getTableHeader(), BorderLayout.NORTH); tablePanel.add(table, BorderLayout.CENTER); getContentPane().add(tablePanel, BorderLayout.SOUTH); jtree.addTreeSelectionListener(this); // REVISIT MouseListener ml = new MouseAdapter() { public void mouseClicked(MouseEvent e) { int selRow = jtree.getRowForLocation(e.getX(), e.getY()); TreePath selPath = jtree.getPathForLocation(e.getX(), e.getY()); if (selRow != -1) { selected_node = makeFQN(selPath.getPath()); jtree.setSelectionPath(selPath); if (e.getModifiers() == java.awt.event.InputEvent.BUTTON3_MASK) { operationsPopup.show(e.getComponent(), e.getX(), e.getY()); } } } }; jtree.addMouseListener(ml); createMenus(); setLocation(50, 50); setSize( getInsets().left + getInsets().right + 485, getInsets().top + getInsets().bottom + 367); init(); setVisible(true); }
@Override public void setSystemManager(SystemManager sm) { super.setSystemManager(sm); sm.getIoService().addIOServiceListener(this); filter.addCaretListener(lumberjack); filter.setAction(lumberjackAction); colors.addTreeSelectionListener(this); itemList.addActionListener(this); sceneElement = null; }
public Browser(CavityNestingDB cndb) throws SQLException { super(new BorderLayout()); setPreferredSize(new Dimension(300, 500)); db = cndb; displayer = new NodeDisplay(); top = new DefaultMutableTreeNode("CavityNestingDB"); tree = new JTree(top); DefaultTreeSelectionModel selModel = new DefaultTreeSelectionModel(); selModel.setSelectionMode(DefaultTreeSelectionModel.SINGLE_TREE_SELECTION); tree.setSelectionModel(selModel); tree.addTreeSelectionListener( new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { if (e.isAddedPath()) { TreePath path = e.getPath(); DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); Object value = node.getUserObject(); // System.out.println(String.valueOf(value)); if (value instanceof CavityDBObject) { displayer.display((CavityDBObject) value); } else { // System.out.println(value.getClass().getSimpleName()); } } } }); JSplitPane splitter = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); add(splitter, BorderLayout.CENTER); splitter.add(new JScrollPane(tree)); splitter.add(displayer); populate(); }