List of utility methods to do JTree
void | scrollTreeToSelectedRow(final JTree tree) scroll Tree To Selected Row final int selectedRow = tree.getLeadSelectionRow(); if (selectedRow >= 0) { SwingUtilities.invokeLater(new Runnable() { public void run() { tree.scrollRectToVisible(tree.getRowBounds(selectedRow)); }); |
void | setComponentTreeEnabled(Component c, boolean enabled) Enables or disables of the components in the tree starting with c . c.setEnabled(enabled); Component[] children = getChildren(c); if (children != null) { for (int i = 0; i < children.length; i++) { setComponentTreeEnabled(children[i], enabled); |
void | setLeftChildIndent(JTree tree, int indent) Set's the left indent in pixels to use for the given JTree 's collapsed and expanded icon. ((BasicTreeUI) tree.getUI()).setLeftChildIndent(indent); |
void | setToolTipOnTree(Container c, String tooltip) Recurse the Component hierarchy, setting the tooltip of each component. for (int i = 0; i < c.getComponentCount(); i++) { Component child = c.getComponent(i); if (child instanceof Container) { setToolTipOnTree((Container) child, tooltip); if (child instanceof JComponent) { ((JComponent) child).setToolTipText(tooltip); |
void | setTreeEnabled(Container container, boolean enabled) set Tree Enabled synchronized (container.getTreeLock()) { for (Component comp : container.getComponents()) { setComponentEnabled(comp, enabled); |
TreeSelectionListener | treeListen(final ActionListener listener) Wrapper for tree selection listeners. return new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { listener.actionPerformed(new ActionEvent(e.getSource(), 0, "bogus commandus")); }; |
void | upMove(JTree tree) up Move DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); if (node == null) return; if (node.isRoot()) return; DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent(); int index = parent.getIndex(node); if (index <= 0) ... |