if (comp == null) { return; applyProperties(comp, "Tree.background", "Tree.foreground", "Tree.font");
Insets insets = DEFAULT_INSETS; Rectangle outer = tree.getVisibleRect(); Rectangle inner = new Rectangle(outer.x + insets.left, outer.y + insets.top, outer.width - (insets.left + insets.right), outer.height - (insets.top + insets.bottom)); if (!inner.contains(cursorLocation)) { Rectangle scrollRect = new Rectangle(cursorLocation.x - insets.left, cursorLocation.y - insets.top, insets.left + insets.right, insets.top + insets.bottom); tree.scrollRectToVisible(scrollRect); ...
Determines whether a tree should be in auto scroll mode.
boolean ret = false; if (tree.getRowCount() < 1) { return ret; Rectangle viewRect = tree.getVisibleRect(); int[] selected = tree.getSelectionRows(); boolean selectedIsVisible = false; if (selected == null) { ...
DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
renderer.setOpenIcon(null);
renderer.setClosedIcon(null);
tree.setCellRenderer(renderer);
FontMetrics metrics = tree.getFontMetrics(tree.getFont()); tree.setRowHeight(Math.max(tree.getRowHeight(), metrics.getHeight()));
TreeModelListener that will automatically expand the tree as new nodes are inserted.
tree.getModel().addTreeModelListener(new TreeModelListener() { public void treeNodesChanged(TreeModelEvent e) { public void treeNodesInserted(TreeModelEvent e) { tree.expandPath(e.getTreePath()); public void treeNodesRemoved(TreeModelEvent e) { public void treeStructureChanged(TreeModelEvent e) { });
TreeNode root = (TreeNode) tree.getModel().getRoot(); return find2(tree, new TreePath(root), names, 0, true);
Component[] components = container.getComponents(); for (Component component : components) { if (component instanceof JTree) { return (JTree) component; } else if (component instanceof Container) { JTree tree = findTree((Container) component); if (tree != null) { return tree; ...