treeScrollPane.setViewportView(componentTree); componentTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); componentTree.addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) {
private void init() { model.addViewerModelListener(this); setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), NLS.nls("AST.PANEL.TITLE"))); setLayout(new BorderLayout()); tree = new JTree((TreeNode) null); tree.addTreeSelectionListener(this); tree.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) { TreePath path = tree.getClosestPathForLocation(e.getX(), e.getY()); tree.setSelectionPath(path); JPopupMenu menu = new ASTNodePopupMenu(model, (Node) path.getLastPathComponent()); menu.show(tree, e.getX(), e.getY()); } } }); add(new JScrollPane(tree), BorderLayout.CENTER); }
tree.getSelectionModel().setSelectionMode (TreeSelectionModel.SINGLE_TREE_SELECTION); tree.addTreeSelectionListener( new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent tse) { if (sortable) {
/** * Constructor * * @param tree The tree to track */ public JTreeUpdater(JTree tree) { this.tree = tree; this.tree.addTreeExpansionListener(this); this.tree.addTreeSelectionListener(this); }
private void init() { panel = new JPanel(new BorderLayout()); statusField = new JTextField(); statusField.setEditable(false); panel.add(statusField); defaultBorder = new BevelBorder(BevelBorder.LOWERED); errorBorder = new BevelBorder(BevelBorder.LOWERED, Color.RED, Color.RED); statusField.setAction(textInputAction); tree.addTreeSelectionListener(this); }
/** Constructor */ public XChartDemo() { super(new GridLayout(1, 0)); // Create the nodes. DefaultMutableTreeNode top = new DefaultMutableTreeNode("XChart Example Charts"); createNodes(top); // Create a tree that allows one selection at a time. tree = new JTree(top); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); // Listen for when the selection changes. tree.addTreeSelectionListener(this); // Create the scroll pane and add the tree to it. JScrollPane treeView = new JScrollPane(tree); // Create Chart Panel chartPanel = new XChartPanel(new AreaChart01().getChart()); // Add the scroll panes to a split pane. splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPane.setTopComponent(treeView); splitPane.setBottomComponent(chartPanel); Dimension minimumSize = new Dimension(130, 160); treeView.setMinimumSize(minimumSize); splitPane.setPreferredSize(new Dimension(700, 700)); // Add the split pane to this panel. add(splitPane); }
protected void init() { // Create the nodes. DefaultMutableTreeNode top = new DefaultMutableTreeNode("XChart Example Charts"); createNodes(top); tree = new JTree(top); // Create a tree that allows one selection at a time. tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); // Listen for when the selection changes. tree.addTreeSelectionListener(this); // Create the scroll pane and add the tree to it. JScrollPane treeView = new JScrollPane(tree); // Create Chart Panel tabbedPane = new JTabbedPane(); for (int i = 0; i < tree.getRowCount(); i++) { tree.expandRow(i); } // select first leaf DefaultMutableTreeNode firstLeaf = top.getFirstLeaf(); tree.setSelectionPath(new TreePath(firstLeaf.getPath())); // Add the scroll panes to a split pane. splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPane.setTopComponent(treeView); splitPane.setBottomComponent(tabbedPane); Dimension minimumSize = new Dimension(130, 160); treeView.setMinimumSize(minimumSize); splitPane.setPreferredSize(new Dimension(700, 700)); // Add the split pane to this panel. add(splitPane); }
/** * Build editor, add tree and mouse listener. */ public CellEditorNode() { this.defaultTreeRenderer = new CellRendererNode(); MediatorGui.treeDatabase().addTreeSelectionListener(this); MediatorGui.treeDatabase().addMouseListener(this); }
/** * Call this method whenever you update the tree and needs it reloaded */ public synchronized void update() { synchronized (this.tree) { this.tree.removeTreeExpansionListener(this); this.tree.removeTreeSelectionListener(this); ((DefaultTreeModel) this.tree.getModel()).reload(); for (TreePath treePath : expandedTreePaths) { this.tree.expandPath(treePath); } this.tree.getSelectionModel().setSelectionPaths(selectedTreePaths); this.tree.addTreeExpansionListener(this); this.tree.addTreeSelectionListener(this); } }
resultsTree.addTreeSelectionListener(treeSelectionListener); final MouseListener treeMouseListener = new ToolWindowMouseListener(); resultsTree.addMouseListener(treeMouseListener);
/** * Adds the tree selection listener. * * @param sel the sel */ // add a tree selection listener to the JTree public void addTreeSelectionListener(TreeSelectionListener sel) { tree.addTreeSelectionListener(sel); }
/** * Called by SwingViewerBuilder, so that SwingController can setup event handling */ public void setOutlineComponents(JTree tree, JScrollPane scroll) { outlinesTree = tree; outlinesScrollPane = scroll; outlinesTree.addTreeSelectionListener(this); }
tree.setModel(model); tree.setCellRenderer(renderer); tree.addTreeSelectionListener(this);
public class Frame1 extends JFrame implements JTreeSelectionListener { private JTree jtree = new JTree(); public Frame1() { jtree.addTreeSelectionListener(this); } public void valueChanged(TreeSelectionEvent e) { // can now access jtree directly ... } }
/** * Registers the specified listener with this tree. * * @param l Tree selection listener. */ public void addTreeSelectionListener(TreeSelectionListener l) { getTree().addTreeSelectionListener(l); }
private void addListeners() { historyTree.addTreeSelectionListener(onTreeSelected()); btnClose.addActionListener(onCloseBtnClick()); btnFind.addActionListener(onFindBtnClick()); }
public TestHierarchyRunView(TestRunContext context) { fTestContext= context; fTreeBrowser= new TestSuitePanel(); fTreeBrowser.getTree().addTreeSelectionListener( new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { testSelected(); } } ); }
protected void createFisheryRegionTree() { $objectMap.put("fisheryRegionTree", fisheryRegionTree = new JTree()); fisheryRegionTree.setName("fisheryRegionTree"); fisheryRegionTree.setRootVisible(true); fisheryRegionTree.setSelectionRow(0); fisheryRegionTree.addTreeSelectionListener(JAXXUtil.getEventListener(TreeSelectionListener.class, "valueChanged", this, "doValueChanged__on__fisheryRegionTree")); }
void setupTreeListeners() { // noinspection ConstantIfStatement if (false) { tree.addTreeExpansionListener(new MyTreeExpansionListener()); } tree.addTreeSelectionListener(new MyTreeSelectionListener()); tree.addMouseListener(new TreeMouseListener()); }
protected void createFisheryRegionTree() { $objectMap.put("fisheryRegionTree", fisheryRegionTree = new JTree()); fisheryRegionTree.setName("fisheryRegionTree"); fisheryRegionTree.setRootVisible(true); fisheryRegionTree.setRowHeight(0); fisheryRegionTree.setSelectionRow(0); fisheryRegionTree.addTreeSelectionListener(JAXXUtil.getEventListener(TreeSelectionListener.class, "valueChanged", this, "doValueChanged__on__fisheryRegionTree")); }