< prev index next >

src/java.desktop/share/classes/javax/swing/JTree.java

Print this page

        

*** 46,88 **** * You can find task-oriented documentation and examples of using trees in * <a href="http://docs.oracle.com/javase/tutorial/uiswing/components/tree.html">How to Use Trees</a>, * a section in <em>The Java Tutorial.</em> * <p> * A specific node in a tree can be identified either by a ! * <code>TreePath</code> (an object * that encapsulates a node and all of its ancestors), or by its * display row, where each row in the display area displays one node. * An <i>expanded</i> node is a non-leaf node (as identified by ! * <code>TreeModel.isLeaf(node)</code> returning false) that will displays * its children when all its ancestors are <i>expanded</i>. * A <i>collapsed</i> * node is one which hides them. A <i>hidden</i> node is one which is * under a collapsed ancestor. All of a <i>viewable</i> nodes parents * are expanded, but may or may not be displayed. A <i>displayed</i> node * is both viewable and in the display area, where it can be seen. * </p> ! * The following <code>JTree</code> methods use "visible" to mean "displayed": * <ul> ! * <li><code>isRootVisible()</code> ! * <li><code>setRootVisible()</code> ! * <li><code>scrollPathToVisible()</code> ! * <li><code>scrollRowToVisible()</code> ! * <li><code>getVisibleRowCount()</code> ! * <li><code>setVisibleRowCount()</code> * </ul> ! * The next group of <code>JTree</code> methods use "visible" to mean * "viewable" (under an expanded parent): * <ul> ! * <li><code>isVisible()</code> ! * <li><code>makeVisible()</code> * </ul> * If you are interested in knowing when the selection changes implement ! * the <code>TreeSelectionListener</code> interface and add the instance ! * using the method <code>addTreeSelectionListener</code>. ! * <code>valueChanged</code> will be invoked when the * selection changes, that is if the user clicks twice on the same ! * node <code>valueChanged</code> will only be invoked once. * <p> * If you are interested in detecting either double-click events or when * a user clicks on a node, regardless of whether or not it was selected, * we recommend you do the following: * </p> --- 46,88 ---- * You can find task-oriented documentation and examples of using trees in * <a href="http://docs.oracle.com/javase/tutorial/uiswing/components/tree.html">How to Use Trees</a>, * a section in <em>The Java Tutorial.</em> * <p> * A specific node in a tree can be identified either by a ! * {@code TreePath} (an object * that encapsulates a node and all of its ancestors), or by its * display row, where each row in the display area displays one node. * An <i>expanded</i> node is a non-leaf node (as identified by ! * {@code TreeModel.isLeaf(node)} returning false) that will displays * its children when all its ancestors are <i>expanded</i>. * A <i>collapsed</i> * node is one which hides them. A <i>hidden</i> node is one which is * under a collapsed ancestor. All of a <i>viewable</i> nodes parents * are expanded, but may or may not be displayed. A <i>displayed</i> node * is both viewable and in the display area, where it can be seen. * </p> ! * The following {@code JTree} methods use "visible" to mean "displayed": * <ul> ! * <li>{@code isRootVisible()} ! * <li>{@code setRootVisible()} ! * <li>{@code scrollPathToVisible()} ! * <li>{@code scrollRowToVisible()} ! * <li>{@code getVisibleRowCount()} ! * <li>{@code setVisibleRowCount()} * </ul> ! * The next group of {@code JTree} methods use "visible" to mean * "viewable" (under an expanded parent): * <ul> ! * <li>{@code isVisible()} ! * <li>{@code makeVisible()} * </ul> * If you are interested in knowing when the selection changes implement ! * the {@code TreeSelectionListener} interface and add the instance ! * using the method {@code addTreeSelectionListener}. ! * {@code valueChanged} will be invoked when the * selection changes, that is if the user clicks twice on the same ! * node {@code valueChanged} will only be invoked once. * <p> * If you are interested in detecting either double-click events or when * a user clicks on a node, regardless of whether or not it was selected, * we recommend you do the following: * </p>
*** 106,123 **** * tree.addMouseListener(ml); * </pre> * NOTE: This example obtains both the path and row, but you only need to * get the one you're interested in. * <p> ! * To use <code>JTree</code> to display compound nodes * (for example, nodes containing both * a graphic icon and text), subclass {@link TreeCellRenderer} and use * {@link #setCellRenderer} to tell the tree to use it. To edit such nodes, * subclass {@link TreeCellEditor} and use {@link #setCellEditor}. * </p> * <p> ! * Like all <code>JComponent</code> classes, you can use {@link InputMap} and * {@link ActionMap} * to associate an {@link Action} object with a {@link KeyStroke} * and execute the action under specified conditions. * </p> * <strong>Warning:</strong> Swing is not thread safe. For more --- 106,123 ---- * tree.addMouseListener(ml); * </pre> * NOTE: This example obtains both the path and row, but you only need to * get the one you're interested in. * <p> ! * To use {@code JTree} to display compound nodes * (for example, nodes containing both * a graphic icon and text), subclass {@link TreeCellRenderer} and use * {@link #setCellRenderer} to tell the tree to use it. To edit such nodes, * subclass {@link TreeCellEditor} and use {@link #setCellEditor}. * </p> * <p> ! * Like all {@code JComponent} classes, you can use {@link InputMap} and * {@link ActionMap} * to associate an {@link Action} object with a {@link KeyStroke} * and execute the action under specified conditions. * </p> * <strong>Warning:</strong> Swing is not thread safe. For more
*** 129,139 **** * Serialized objects of this class will not be compatible with * future Swing releases. The current serialization support is * appropriate for short term storage or RMI between applications running * the same version of Swing. As of 1.4, support for long term storage * of all JavaBeans&trade; ! * has been added to the <code>java.beans</code> package. * Please see {@link java.beans.XMLEncoder}. *</p> * @beaninfo * attribute: isContainer false * description: A component that displays a set of hierarchical data as an outline. --- 129,139 ---- * Serialized objects of this class will not be compatible with * future Swing releases. The current serialization support is * appropriate for short term storage or RMI between applications running * the same version of Swing. As of 1.4, support for long term storage * of all JavaBeans&trade; ! * has been added to the {@code java.beans} package. * Please see {@link java.beans.XMLEncoder}. *</p> * @beaninfo * attribute: isContainer false * description: A component that displays a set of hierarchical data as an outline.
*** 167,178 **** * the highest visible nodes. */ protected boolean rootVisible; /** ! * The cell used to draw nodes. If <code>null</code>, the UI uses a default ! * <code>cellRenderer</code>. */ protected transient TreeCellRenderer cellRenderer; /** * Height to use for each display row. If this is &lt;= 0 the renderer --- 167,178 ---- * the highest visible nodes. */ protected boolean rootVisible; /** ! * The cell used to draw nodes. If {@code null}, the UI uses a default ! * {@code cellRenderer}. */ protected transient TreeCellRenderer cellRenderer; /** * Height to use for each display row. If this is &lt;= 0 the renderer
*** 180,190 **** */ protected int rowHeight; private boolean rowHeightSet = false; /** ! * Maps from <code>TreePath</code> to <code>Boolean</code> * indicating whether or not the * particular path is expanded. This ONLY indicates whether a * given path is expanded, and NOT if it is visible or not. That * information must be determined by visiting all the parent * paths and seeing if they are visible. --- 180,190 ---- */ protected int rowHeight; private boolean rowHeightSet = false; /** ! * Maps from {@code TreePath} to {@code Boolean} * indicating whether or not the * particular path is expanded. This ONLY indicates whether a * given path is expanded, and NOT if it is visible or not. That * information must be determined by visiting all the parent * paths and seeing if they are visible.
*** 199,209 **** * allows the user to click once to expand or collapse the node. A * common interface shows a plus sign (+) for a node which can be * expanded and a minus sign (-) for a node which can be collapsed. * Handles are always shown for nodes below the topmost level. * <p> ! * If the <code>rootVisible</code> setting specifies that the root * node is to be displayed, then that is the only node at the topmost * level. If the root node is not displayed, then all of its * children are at the topmost level of the tree. Handles are * always displayed for nodes other than the topmost. * <p> --- 199,209 ---- * allows the user to click once to expand or collapse the node. A * common interface shows a plus sign (+) for a node which can be * expanded and a minus sign (-) for a node which can be collapsed. * Handles are always shown for nodes below the topmost level. * <p> ! * If the {@code rootVisible} setting specifies that the root * node is to be displayed, then that is the only node at the topmost * level. If the root node is not displayed, then all of its * children are at the topmost level of the tree. Handles are * always displayed for nodes other than the topmost. * <p>
*** 217,232 **** protected boolean showsRootHandles; private boolean showsRootHandlesSet = false; /** * Creates a new event and passed it off the ! * <code>selectionListeners</code>. */ protected transient TreeSelectionRedirector selectionRedirector; /** ! * Editor for the entries. Default is <code>null</code> * (tree is not editable). */ protected transient TreeCellEditor cellEditor; /** --- 217,232 ---- protected boolean showsRootHandles; private boolean showsRootHandlesSet = false; /** * Creates a new event and passed it off the ! * {@code selectionListeners}. */ protected transient TreeSelectionRedirector selectionRedirector; /** ! * Editor for the entries. Default is {@code null} * (tree is not editable). */ protected transient TreeCellEditor cellEditor; /**
*** 246,265 **** */ protected boolean largeModel; /** * Number of rows to make visible at one time. This value is used for ! * the <code>Scrollable</code> interface. It determines the preferred * size of the display area. */ protected int visibleRowCount; /** * If true, when editing is to be stopped by way of selection changing, ! * data in tree changing or other means <code>stopCellEditing</code> * is invoked, and changes are saved. If false, ! * <code>cancelCellEditing</code> is invoked, and changes * are discarded. Default is false. */ protected boolean invokesStopCellEditing; /** --- 246,265 ---- */ protected boolean largeModel; /** * Number of rows to make visible at one time. This value is used for ! * the {@code Scrollable} interface. It determines the preferred * size of the display area. */ protected int visibleRowCount; /** * If true, when editing is to be stopped by way of selection changing, ! * data in tree changing or other means {@code stopCellEditing} * is invoked, and changes are saved. If false, ! * {@code cancelCellEditing} is invoked, and changes * are discarded. Default is false. */ protected boolean invokesStopCellEditing; /**
*** 273,294 **** * Number of mouse clicks before a node is expanded. */ protected int toggleClickCount; /** ! * Updates the <code>expandedState</code>. */ protected transient TreeModelListener treeModelListener; /** ! * Used when <code>setExpandedState</code> is invoked, ! * will be a <code>Stack</code> of <code>Stack</code>s. */ private transient Stack<Stack<TreePath>> expandedStack; /** ! * Lead selection path, may not be <code>null</code>. */ private TreePath leadPath; /** * Anchor path. --- 273,294 ---- * Number of mouse clicks before a node is expanded. */ protected int toggleClickCount; /** ! * Updates the {@code expandedState}. */ protected transient TreeModelListener treeModelListener; /** ! * Used when {@code setExpandedState} is invoked, ! * will be a {@code Stack} of {@code Stack}s. */ private transient Stack<Stack<TreePath>> expandedStack; /** ! * Lead selection path, may not be {@code null}. */ private TreePath leadPath; /** * Anchor path.
*** 299,309 **** * True if paths in the selection should be expanded. */ private boolean expandsSelectedPaths; /** ! * This is set to true for the life of the <code>setUI</code> call. */ private boolean settingUI; /** If true, mouse presses on selections initiate a drag operation. */ private boolean dragEnabled; --- 299,309 ---- * True if paths in the selection should be expanded. */ private boolean expandsSelectedPaths; /** ! * This is set to true for the life of the {@code setUI} call. */ private boolean settingUI; /** If true, mouse presses on selections initiate a drag operation. */ private boolean dragEnabled;
*** 317,328 **** * The drop location. */ private transient DropLocation dropLocation; /** ! * A subclass of <code>TransferHandler.DropLocation</code> representing ! * a drop location for a <code>JTree</code>. * * @see #getDropLocation * @since 1.6 */ public static final class DropLocation extends TransferHandler.DropLocation { --- 317,328 ---- * The drop location. */ private transient DropLocation dropLocation; /** ! * A subclass of {@code TransferHandler.DropLocation} representing ! * a drop location for a {@code JTree}. * * @see #getDropLocation * @since 1.6 */ public static final class DropLocation extends TransferHandler.DropLocation {
*** 335,361 **** this.index = index; } /** * Returns the index where the dropped data should be inserted ! * with respect to the path returned by <code>getPath()</code>. * <p> ! * For drop modes <code>DropMode.USE_SELECTION</code> and ! * <code>DropMode.ON</code>, this index is unimportant (and it will ! * always be <code>-1</code>) as the only interesting data is the * path over which the drop operation occurred. * <p> ! * For drop mode <code>DropMode.INSERT</code>, this index * indicates the index at which the data should be inserted into ! * the parent path represented by <code>getPath()</code>. ! * <code>-1</code> indicates that the drop occurred over the * parent itself, and in most cases should be treated as inserting * into either the beginning or the end of the parent's list of * children. * <p> ! * For <code>DropMode.ON_OR_INSERT</code>, this value will be ! * an insert index, as described above, or <code>-1</code> if * the drop occurred over the path itself. * * @return the child index * @see #getPath */ --- 335,361 ---- this.index = index; } /** * Returns the index where the dropped data should be inserted ! * with respect to the path returned by {@code getPath()}. * <p> ! * For drop modes {@code DropMode.USE_SELECTION} and ! * {@code DropMode.ON}, this index is unimportant (and it will ! * always be {@code -1}) as the only interesting data is the * path over which the drop operation occurred. * <p> ! * For drop mode {@code DropMode.INSERT}, this index * indicates the index at which the data should be inserted into ! * the parent path represented by {@code getPath()}. ! * {@code -1} indicates that the drop occurred over the * parent itself, and in most cases should be treated as inserting * into either the beginning or the end of the parent's list of * children. * <p> ! * For {@code DropMode.ON_OR_INSERT}, this value will be ! * an insert index, as described above, or {@code -1} if * the drop occurred over the path itself. * * @return the child index * @see #getPath */
*** 366,401 **** /** * Returns the path where dropped data should be placed in the * tree. * <p> * Interpretation of this value depends on the drop mode set on the ! * component. If the drop mode is <code>DropMode.USE_SELECTION</code> ! * or <code>DropMode.ON</code>, the return value is the path in the * tree over which the data has been (or will be) dropped. ! * <code>null</code> indicates that the drop is over empty space, * not associated with a particular path. * <p> ! * If the drop mode is <code>DropMode.INSERT</code>, the return value * refers to the path that should become the parent of the new data, ! * in which case <code>getChildIndex()</code> indicates where the * new item should be inserted into this parent path. A ! * <code>null</code> path indicates that no parent path has been * determined, which can happen for multiple reasons: * <ul> * <li>The tree has no model * <li>There is no root in the tree * <li>The root is collapsed * <li>The root is a leaf node * </ul> * It is up to the developer to decide if and how they wish to handle ! * the <code>null</code> case. * <p> ! * If the drop mode is <code>DropMode.ON_OR_INSERT</code>, ! * <code>getChildIndex</code> can be used to determine whether the ! * drop is on top of the path itself (<code>-1</code>) or the index * at which it should be inserted into the path (values other than ! * <code>-1</code>). * * @return the drop path * @see #getChildIndex */ public TreePath getPath() { --- 366,401 ---- /** * Returns the path where dropped data should be placed in the * tree. * <p> * Interpretation of this value depends on the drop mode set on the ! * component. If the drop mode is {@code DropMode.USE_SELECTION} ! * or {@code DropMode.ON}, the return value is the path in the * tree over which the data has been (or will be) dropped. ! * {@code null} indicates that the drop is over empty space, * not associated with a particular path. * <p> ! * If the drop mode is {@code DropMode.INSERT}, the return value * refers to the path that should become the parent of the new data, ! * in which case {@code getChildIndex()} indicates where the * new item should be inserted into this parent path. A ! * {@code null} path indicates that no parent path has been * determined, which can happen for multiple reasons: * <ul> * <li>The tree has no model * <li>There is no root in the tree * <li>The root is collapsed * <li>The root is a leaf node * </ul> * It is up to the developer to decide if and how they wish to handle ! * the {@code null} case. * <p> ! * If the drop mode is {@code DropMode.ON_OR_INSERT}, ! * {@code getChildIndex} can be used to determine whether the ! * drop is on top of the path itself ({@code -1}) or the index * at which it should be inserted into the path (values other than ! * {@code -1}). * * @return the drop path * @see #getChildIndex */ public TreePath getPath() {
*** 439,452 **** * A timer to expand nodes during drop. */ private TreeTimer dropTimer; /** ! * When <code>addTreeExpansionListener</code> is invoked, ! * and <code>settingUI</code> is true, this ivar gets set to the passed in ! * <code>Listener</code>. This listener is then notified first in ! * <code>fireTreeCollapsed</code> and <code>fireTreeExpanded</code>. * <p>This is an ugly workaround for a way to have the UI listener * get notified before other listeners. */ private transient TreeExpansionListener uiTreeExpansionListener; --- 439,452 ---- * A timer to expand nodes during drop. */ private TreeTimer dropTimer; /** ! * When {@code addTreeExpansionListener} is invoked, ! * and {@code settingUI} is true, this ivar gets set to the passed in ! * {@code Listener}. This listener is then notified first in ! * {@code fireTreeCollapsed} and {@code fireTreeExpanded}. * <p>This is an ugly workaround for a way to have the UI listener * get notified before other listeners. */ private transient TreeExpansionListener uiTreeExpansionListener;
*** 456,492 **** private static int TEMP_STACK_SIZE = 11; // // Bound property names // ! /** Bound property name for <code>cellRenderer</code>. */ public static final String CELL_RENDERER_PROPERTY = "cellRenderer"; ! /** Bound property name for <code>treeModel</code>. */ public static final String TREE_MODEL_PROPERTY = "model"; ! /** Bound property name for <code>rootVisible</code>. */ public static final String ROOT_VISIBLE_PROPERTY = "rootVisible"; ! /** Bound property name for <code>showsRootHandles</code>. */ public static final String SHOWS_ROOT_HANDLES_PROPERTY = "showsRootHandles"; ! /** Bound property name for <code>rowHeight</code>. */ public static final String ROW_HEIGHT_PROPERTY = "rowHeight"; ! /** Bound property name for <code>cellEditor</code>. */ public static final String CELL_EDITOR_PROPERTY = "cellEditor"; ! /** Bound property name for <code>editable</code>. */ public static final String EDITABLE_PROPERTY = "editable"; ! /** Bound property name for <code>largeModel</code>. */ public static final String LARGE_MODEL_PROPERTY = "largeModel"; /** Bound property name for selectionModel. */ public static final String SELECTION_MODEL_PROPERTY = "selectionModel"; ! /** Bound property name for <code>visibleRowCount</code>. */ public static final String VISIBLE_ROW_COUNT_PROPERTY = "visibleRowCount"; ! /** Bound property name for <code>messagesStopCellEditing</code>. */ public static final String INVOKES_STOP_CELL_EDITING_PROPERTY = "invokesStopCellEditing"; ! /** Bound property name for <code>scrollsOnExpand</code>. */ public static final String SCROLLS_ON_EXPAND_PROPERTY = "scrollsOnExpand"; ! /** Bound property name for <code>toggleClickCount</code>. */ public static final String TOGGLE_CLICK_COUNT_PROPERTY = "toggleClickCount"; ! /** Bound property name for <code>leadSelectionPath</code>. * @since 1.3 */ public static final String LEAD_SELECTION_PATH_PROPERTY = "leadSelectionPath"; /** Bound property name for anchor selection path. * @since 1.3 */ public static final String ANCHOR_SELECTION_PATH_PROPERTY = "anchorSelectionPath"; --- 456,492 ---- private static int TEMP_STACK_SIZE = 11; // // Bound property names // ! /** Bound property name for {@code cellRenderer}. */ public static final String CELL_RENDERER_PROPERTY = "cellRenderer"; ! /** Bound property name for {@code treeModel}. */ public static final String TREE_MODEL_PROPERTY = "model"; ! /** Bound property name for {@code rootVisible}. */ public static final String ROOT_VISIBLE_PROPERTY = "rootVisible"; ! /** Bound property name for {@code showsRootHandles}. */ public static final String SHOWS_ROOT_HANDLES_PROPERTY = "showsRootHandles"; ! /** Bound property name for {@code rowHeight}. */ public static final String ROW_HEIGHT_PROPERTY = "rowHeight"; ! /** Bound property name for {@code cellEditor}. */ public static final String CELL_EDITOR_PROPERTY = "cellEditor"; ! /** Bound property name for {@code editable}. */ public static final String EDITABLE_PROPERTY = "editable"; ! /** Bound property name for {@code largeModel}. */ public static final String LARGE_MODEL_PROPERTY = "largeModel"; /** Bound property name for selectionModel. */ public static final String SELECTION_MODEL_PROPERTY = "selectionModel"; ! /** Bound property name for {@code visibleRowCount}. */ public static final String VISIBLE_ROW_COUNT_PROPERTY = "visibleRowCount"; ! /** Bound property name for {@code messagesStopCellEditing}. */ public static final String INVOKES_STOP_CELL_EDITING_PROPERTY = "invokesStopCellEditing"; ! /** Bound property name for {@code scrollsOnExpand}. */ public static final String SCROLLS_ON_EXPAND_PROPERTY = "scrollsOnExpand"; ! /** Bound property name for {@code toggleClickCount}. */ public static final String TOGGLE_CLICK_COUNT_PROPERTY = "toggleClickCount"; ! /** Bound property name for {@code leadSelectionPath}. * @since 1.3 */ public static final String LEAD_SELECTION_PATH_PROPERTY = "leadSelectionPath"; /** Bound property name for anchor selection path. * @since 1.3 */ public static final String ANCHOR_SELECTION_PATH_PROPERTY = "anchorSelectionPath";
*** 494,507 **** * @since 1.3 */ public static final String EXPANDS_SELECTED_PATHS_PROPERTY = "expandsSelectedPaths"; /** ! * Creates and returns a sample <code>TreeModel</code>. * Used primarily for beanbuilders to show something interesting. * ! * @return the default <code>TreeModel</code> */ protected static TreeModel getDefaultTreeModel() { DefaultMutableTreeNode root = new DefaultMutableTreeNode("JTree"); DefaultMutableTreeNode parent; --- 494,507 ---- * @since 1.3 */ public static final String EXPANDS_SELECTED_PATHS_PROPERTY = "expandsSelectedPaths"; /** ! * Creates and returns a sample {@code TreeModel}. * Used primarily for beanbuilders to show something interesting. * ! * @return the default {@code TreeModel} */ protected static TreeModel getDefaultTreeModel() { DefaultMutableTreeNode root = new DefaultMutableTreeNode("JTree"); DefaultMutableTreeNode parent;
*** 527,548 **** parent.add(new DefaultMutableTreeNode("bananas")); return new DefaultTreeModel(root); } /** ! * Returns a <code>TreeModel</code> wrapping the specified object. * If the object is:<ul> ! * <li>an array of <code>Object</code>s, ! * <li>a <code>Hashtable</code>, or ! * <li>a <code>Vector</code> * </ul>then a new root node is created with each of the incoming * objects as children. Otherwise, a new root is created with * a value of {@code "root"}. * ! * @param value the <code>Object</code> used as the foundation for ! * the <code>TreeModel</code> ! * @return a <code>TreeModel</code> wrapping the specified object */ protected static TreeModel createTreeModel(Object value) { DefaultMutableTreeNode root; if((value instanceof Object[]) || (value instanceof Hashtable) || --- 527,548 ---- parent.add(new DefaultMutableTreeNode("bananas")); return new DefaultTreeModel(root); } /** ! * Returns a {@code TreeModel} wrapping the specified object. * If the object is:<ul> ! * <li>an array of {@code Object}s, ! * <li>a {@code Hashtable}, or ! * <li>a {@code Vector} * </ul>then a new root node is created with each of the incoming * objects as children. Otherwise, a new root is created with * a value of {@code "root"}. * ! * @param value the {@code Object} used as the foundation for ! * the {@code TreeModel} ! * @return a {@code TreeModel} wrapping the specified object */ protected static TreeModel createTreeModel(Object value) { DefaultMutableTreeNode root; if((value instanceof Object[]) || (value instanceof Hashtable) ||
*** 555,658 **** } return new DefaultTreeModel(root, false); } /** ! * Returns a <code>JTree</code> with a sample model. * The default model used by the tree defines a leaf node as any node * without children. * * @see DefaultTreeModel#asksAllowsChildren */ public JTree() { this(getDefaultTreeModel()); } /** ! * Returns a <code>JTree</code> with each element of the * specified array as the * child of a new root node which is not displayed. * By default, the tree defines a leaf node as any node without * children. * ! * @param value an array of <code>Object</code>s * @see DefaultTreeModel#asksAllowsChildren */ public JTree(Object[] value) { this(createTreeModel(value)); this.setRootVisible(false); this.setShowsRootHandles(true); expandRoot(); } /** ! * Returns a <code>JTree</code> with each element of the specified ! * <code>Vector</code> as the * child of a new root node which is not displayed. By default, the * tree defines a leaf node as any node without children. * ! * @param value a <code>Vector</code> * @see DefaultTreeModel#asksAllowsChildren */ public JTree(Vector<?> value) { this(createTreeModel(value)); this.setRootVisible(false); this.setShowsRootHandles(true); expandRoot(); } /** ! * Returns a <code>JTree</code> created from a <code>Hashtable</code> * which does not display with root. ! * Each value-half of the key/value pairs in the <code>HashTable</code> * becomes a child of the new root node. By default, the tree defines * a leaf node as any node without children. * ! * @param value a <code>Hashtable</code> * @see DefaultTreeModel#asksAllowsChildren */ public JTree(Hashtable<?,?> value) { this(createTreeModel(value)); this.setRootVisible(false); this.setShowsRootHandles(true); expandRoot(); } /** ! * Returns a <code>JTree</code> with the specified ! * <code>TreeNode</code> as its root, * which displays the root node. * By default, the tree defines a leaf node as any node without children. * ! * @param root a <code>TreeNode</code> object * @see DefaultTreeModel#asksAllowsChildren */ public JTree(TreeNode root) { this(root, false); } /** ! * Returns a <code>JTree</code> with the specified <code>TreeNode</code> * as its root, which * displays the root node and which decides whether a node is a * leaf node in the specified manner. * ! * @param root a <code>TreeNode</code> object * @param asksAllowsChildren if false, any node without children is a * leaf node; if true, only nodes that do not allow * children are leaf nodes * @see DefaultTreeModel#asksAllowsChildren */ public JTree(TreeNode root, boolean asksAllowsChildren) { this(new DefaultTreeModel(root, asksAllowsChildren)); } /** ! * Returns an instance of <code>JTree</code> which displays the root node * -- the tree is created using the specified data model. * ! * @param newModel the <code>TreeModel</code> to use as the data model */ @ConstructorProperties({"model"}) public JTree(TreeModel newModel) { super(); expandedStack = new Stack<Stack<TreePath>>(); --- 555,658 ---- } return new DefaultTreeModel(root, false); } /** ! * Returns a {@code JTree} with a sample model. * The default model used by the tree defines a leaf node as any node * without children. * * @see DefaultTreeModel#asksAllowsChildren */ public JTree() { this(getDefaultTreeModel()); } /** ! * Returns a {@code JTree} with each element of the * specified array as the * child of a new root node which is not displayed. * By default, the tree defines a leaf node as any node without * children. * ! * @param value an array of {@code Object}s * @see DefaultTreeModel#asksAllowsChildren */ public JTree(Object[] value) { this(createTreeModel(value)); this.setRootVisible(false); this.setShowsRootHandles(true); expandRoot(); } /** ! * Returns a {@code JTree} with each element of the specified ! * {@code Vector} as the * child of a new root node which is not displayed. By default, the * tree defines a leaf node as any node without children. * ! * @param value a {@code Vector} * @see DefaultTreeModel#asksAllowsChildren */ public JTree(Vector<?> value) { this(createTreeModel(value)); this.setRootVisible(false); this.setShowsRootHandles(true); expandRoot(); } /** ! * Returns a {@code JTree} created from a {@code Hashtable} * which does not display with root. ! * Each value-half of the key/value pairs in the {@code HashTable} * becomes a child of the new root node. By default, the tree defines * a leaf node as any node without children. * ! * @param value a {@code Hashtable} * @see DefaultTreeModel#asksAllowsChildren */ public JTree(Hashtable<?,?> value) { this(createTreeModel(value)); this.setRootVisible(false); this.setShowsRootHandles(true); expandRoot(); } /** ! * Returns a {@code JTree} with the specified ! * {@code TreeNode} as its root, * which displays the root node. * By default, the tree defines a leaf node as any node without children. * ! * @param root a {@code TreeNode} object * @see DefaultTreeModel#asksAllowsChildren */ public JTree(TreeNode root) { this(root, false); } /** ! * Returns a {@code JTree} with the specified {@code TreeNode} * as its root, which * displays the root node and which decides whether a node is a * leaf node in the specified manner. * ! * @param root a {@code TreeNode} object * @param asksAllowsChildren if false, any node without children is a * leaf node; if true, only nodes that do not allow * children are leaf nodes * @see DefaultTreeModel#asksAllowsChildren */ public JTree(TreeNode root, boolean asksAllowsChildren) { this(new DefaultTreeModel(root, asksAllowsChildren)); } /** ! * Returns an instance of {@code JTree} which displays the root node * -- the tree is created using the specified data model. * ! * @param newModel the {@code TreeModel} to use as the data model */ @ConstructorProperties({"model"}) public JTree(TreeModel newModel) { super(); expandedStack = new Stack<Stack<TreePath>>();
*** 672,693 **** } /** * Returns the L&amp;F object that renders this component. * ! * @return the <code>TreeUI</code> object that renders this component */ public TreeUI getUI() { return (TreeUI)ui; } /** * Sets the L&amp;F object that renders this component. * <p> * This is a bound property. * ! * @param ui the <code>TreeUI</code> L&amp;F object * @see UIDefaults#getUI * @beaninfo * bound: true * hidden: true * attribute: visualUpdate true --- 672,693 ---- } /** * Returns the L&amp;F object that renders this component. * ! * @return the {@code TreeUI} object that renders this component */ public TreeUI getUI() { return (TreeUI)ui; } /** * Sets the L&amp;F object that renders this component. * <p> * This is a bound property. * ! * @param ui the {@code TreeUI} L&amp;F object * @see UIDefaults#getUI * @beaninfo * bound: true * hidden: true * attribute: visualUpdate true
*** 705,717 **** } } } /** ! * Notification from the <code>UIManager</code> that the L&amp;F has changed. * Replaces the current UI object with the latest version from the ! * <code>UIManager</code>. * * @see JComponent#updateUI */ public void updateUI() { setUI((TreeUI)UIManager.getUI(this)); --- 705,717 ---- } } } /** ! * Notification from the {@code UIManager} that the L&amp;F has changed. * Replaces the current UI object with the latest version from the ! * {@code UIManager}. * * @see JComponent#updateUI */ public void updateUI() { setUI((TreeUI)UIManager.getUI(this));
*** 732,757 **** return uiClassID; } /** ! * Returns the current <code>TreeCellRenderer</code> * that is rendering each cell. * ! * @return the <code>TreeCellRenderer</code> that is rendering each cell */ public TreeCellRenderer getCellRenderer() { return cellRenderer; } /** ! * Sets the <code>TreeCellRenderer</code> that will be used to * draw each cell. * <p> * This is a bound property. * ! * @param x the <code>TreeCellRenderer</code> that is to render each cell * @beaninfo * bound: true * description: The TreeCellRenderer that will be used to draw * each cell. */ --- 732,757 ---- return uiClassID; } /** ! * Returns the current {@code TreeCellRenderer} * that is rendering each cell. * ! * @return the {@code TreeCellRenderer} that is rendering each cell */ public TreeCellRenderer getCellRenderer() { return cellRenderer; } /** ! * Sets the {@code TreeCellRenderer} that will be used to * draw each cell. * <p> * This is a bound property. * ! * @param x the {@code TreeCellRenderer} that is to render each cell * @beaninfo * bound: true * description: The TreeCellRenderer that will be used to draw * each cell. */
*** 796,813 **** public boolean isEditable() { return editable; } /** ! * Sets the cell editor. A <code>null</code> value implies that the * tree cannot be edited. If this represents a change in the ! * <code>cellEditor</code>, the <code>propertyChange</code> * method is invoked on all listeners. * <p> * This is a bound property. * ! * @param cellEditor the <code>TreeCellEditor</code> to use * @beaninfo * bound: true * description: The cell editor. A null value implies the tree * cannot be edited. */ --- 796,813 ---- public boolean isEditable() { return editable; } /** ! * Sets the cell editor. A {@code null} value implies that the * tree cannot be edited. If this represents a change in the ! * {@code cellEditor}, the {@code propertyChange} * method is invoked on all listeners. * <p> * This is a bound property. * ! * @param cellEditor the {@code TreeCellEditor} to use * @beaninfo * bound: true * description: The cell editor. A null value implies the tree * cannot be edited. */
*** 820,851 **** } /** * Returns the editor used to edit entries in the tree. * ! * @return the <code>TreeCellEditor</code> in use, ! * or <code>null</code> if the tree cannot be edited */ public TreeCellEditor getCellEditor() { return cellEditor; } /** ! * Returns the <code>TreeModel</code> that is providing the data. * ! * @return the <code>TreeModel</code> that is providing the data */ public TreeModel getModel() { return treeModel; } /** ! * Sets the <code>TreeModel</code> that will provide the data. * <p> * This is a bound property. * ! * @param newModel the <code>TreeModel</code> that is to provide the data * @beaninfo * bound: true * description: The TreeModel that will provide the data. */ public void setModel(TreeModel newModel) { --- 820,851 ---- } /** * Returns the editor used to edit entries in the tree. * ! * @return the {@code TreeCellEditor} in use, ! * or {@code null} if the tree cannot be edited */ public TreeCellEditor getCellEditor() { return cellEditor; } /** ! * Returns the {@code TreeModel} that is providing the data. * ! * @return the {@code TreeModel} that is providing the data */ public TreeModel getModel() { return treeModel; } /** ! * Sets the {@code TreeModel} that will provide the data. * <p> * This is a bound property. * ! * @param newModel the {@code TreeModel} that is to provide the data * @beaninfo * bound: true * description: The TreeModel that will provide the data. */ public void setModel(TreeModel newModel) {
*** 895,905 **** return rootVisible; } /** * Determines whether or not the root node from ! * the <code>TreeModel</code> is visible. * <p> * This is a bound property. * * @param rootVisible true if the root node of the tree is to be displayed * @see #rootVisible --- 895,905 ---- return rootVisible; } /** * Determines whether or not the root node from ! * the {@code TreeModel} is visible. * <p> * This is a bound property. * * @param rootVisible true if the root node of the tree is to be displayed * @see #rootVisible
*** 917,937 **** ((AccessibleJTree)accessibleContext).fireVisibleDataPropertyChange(); } } /** ! * Sets the value of the <code>showsRootHandles</code> property, * which specifies whether the node handles should be displayed. * The default value of this property depends on the constructor ! * used to create the <code>JTree</code>. * Some look and feels might not support handles; * they will ignore this property. * <p> * This is a bound property. * ! * @param newValue <code>true</code> if root handles should be displayed; ! * otherwise, <code>false</code> * @see #showsRootHandles * @see #getShowsRootHandles * @beaninfo * bound: true * description: Whether the node handles are to be --- 917,937 ---- ((AccessibleJTree)accessibleContext).fireVisibleDataPropertyChange(); } } /** ! * Sets the value of the {@code showsRootHandles} property, * which specifies whether the node handles should be displayed. * The default value of this property depends on the constructor ! * used to create the {@code JTree}. * Some look and feels might not support handles; * they will ignore this property. * <p> * This is a bound property. * ! * @param newValue {@code true} if root handles should be displayed; ! * otherwise, {@code false} * @see #showsRootHandles * @see #getShowsRootHandles * @beaninfo * bound: true * description: Whether the node handles are to be
*** 950,962 **** } invalidate(); } /** ! * Returns the value of the <code>showsRootHandles</code> property. * ! * @return the value of the <code>showsRootHandles</code> property * @see #showsRootHandles */ public boolean getShowsRootHandles() { return showsRootHandles; --- 950,962 ---- } invalidate(); } /** ! * Returns the value of the {@code showsRootHandles} property. * ! * @return the value of the {@code showsRootHandles} property * @see #showsRootHandles */ public boolean getShowsRootHandles() { return showsRootHandles;
*** 1038,1055 **** } /** * Determines what happens when editing is interrupted by selecting * another node in the tree, a change in the tree's data, or by some ! * other means. Setting this property to <code>true</code> causes the * changes to be automatically saved when editing is interrupted. * <p> * Fires a property change for the INVOKES_STOP_CELL_EDITING_PROPERTY. * ! * @param newValue true means that <code>stopCellEditing</code> is invoked * when editing is interrupted, and data is saved; false means that ! * <code>cancelCellEditing</code> is invoked, and changes are lost * @beaninfo * bound: true * description: Determines what happens when editing is interrupted, * selecting another node in the tree, a change in the * tree's data, or some other means. --- 1038,1055 ---- } /** * Determines what happens when editing is interrupted by selecting * another node in the tree, a change in the tree's data, or by some ! * other means. Setting this property to {@code true} causes the * changes to be automatically saved when editing is interrupted. * <p> * Fires a property change for the INVOKES_STOP_CELL_EDITING_PROPERTY. * ! * @param newValue true means that {@code stopCellEditing} is invoked * when editing is interrupted, and data is saved; false means that ! * {@code cancelCellEditing} is invoked, and changes are lost * @beaninfo * bound: true * description: Determines what happens when editing is interrupted, * selecting another node in the tree, a change in the * tree's data, or some other means.
*** 1073,1096 **** public boolean getInvokesStopCellEditing() { return invokesStopCellEditing; } /** ! * Sets the <code>scrollsOnExpand</code> property, * which determines whether the * tree might scroll to show previously hidden children. ! * If this property is <code>true</code> (the default), * when a node expands * the tree can use scrolling to make * the maximum possible number of the node's descendants visible. * In some look and feels, trees might not need to scroll when expanded; * those look and feels will ignore this property. * <p> * This is a bound property. * ! * @param newValue <code>false</code> to disable scrolling on expansion; ! * <code>true</code> to enable it * @see #getScrollsOnExpand * * @beaninfo * bound: true * description: Indicates if a node descendant should be scrolled when expanded. --- 1073,1096 ---- public boolean getInvokesStopCellEditing() { return invokesStopCellEditing; } /** ! * Sets the {@code scrollsOnExpand} property, * which determines whether the * tree might scroll to show previously hidden children. ! * If this property is {@code true} (the default), * when a node expands * the tree can use scrolling to make * the maximum possible number of the node's descendants visible. * In some look and feels, trees might not need to scroll when expanded; * those look and feels will ignore this property. * <p> * This is a bound property. * ! * @param newValue {@code false} to disable scrolling on expansion; ! * {@code true} to enable it * @see #getScrollsOnExpand * * @beaninfo * bound: true * description: Indicates if a node descendant should be scrolled when expanded.
*** 1103,1115 **** firePropertyChange(SCROLLS_ON_EXPAND_PROPERTY, oldValue, newValue); } /** ! * Returns the value of the <code>scrollsOnExpand</code> property. * ! * @return the value of the <code>scrollsOnExpand</code> property */ public boolean getScrollsOnExpand() { return scrollsOnExpand; } --- 1103,1115 ---- firePropertyChange(SCROLLS_ON_EXPAND_PROPERTY, oldValue, newValue); } /** ! * Returns the value of the {@code scrollsOnExpand} property. * ! * @return the value of the {@code scrollsOnExpand} property */ public boolean getScrollsOnExpand() { return scrollsOnExpand; }
*** 1142,1165 **** public int getToggleClickCount() { return toggleClickCount; } /** ! * Configures the <code>expandsSelectedPaths</code> property. If * true, any time the selection is changed, either via the ! * <code>TreeSelectionModel</code>, or the cover methods provided by ! * <code>JTree</code>, the <code>TreePath</code>s parents will be * expanded to make them visible (visible meaning the parent path is * expanded, not necessarily in the visible rectangle of the ! * <code>JTree</code>). If false, when the selection * changes the nodes parent is not made visible (all its parents expanded). * This is useful if you wish to have your selection model maintain paths * that are not always visible (all parents expanded). * <p> * This is a bound property. * ! * @param newValue the new value for <code>expandsSelectedPaths</code> * * @since 1.3 * @beaninfo * bound: true * description: Indicates whether changes to the selection should make --- 1142,1165 ---- public int getToggleClickCount() { return toggleClickCount; } /** ! * Configures the {@code expandsSelectedPaths} property. If * true, any time the selection is changed, either via the ! * {@code TreeSelectionModel}, or the cover methods provided by ! * {@code JTree}, the {@code TreePath}s parents will be * expanded to make them visible (visible meaning the parent path is * expanded, not necessarily in the visible rectangle of the ! * {@code JTree}). If false, when the selection * changes the nodes parent is not made visible (all its parents expanded). * This is useful if you wish to have your selection model maintain paths * that are not always visible (all parents expanded). * <p> * This is a bound property. * ! * @param newValue the new value for {@code expandsSelectedPaths} * * @since 1.3 * @beaninfo * bound: true * description: Indicates whether changes to the selection should make
*** 1172,1182 **** firePropertyChange(EXPANDS_SELECTED_PATHS_PROPERTY, oldValue, newValue); } /** ! * Returns the <code>expandsSelectedPaths</code> property. * @return true if selection changes result in the parent path being * expanded * @since 1.3 * @see #setExpandsSelectedPaths */ --- 1172,1182 ---- firePropertyChange(EXPANDS_SELECTED_PATHS_PROPERTY, oldValue, newValue); } /** ! * Returns the {@code expandsSelectedPaths} property. * @return true if selection changes result in the parent path being * expanded * @since 1.3 * @see #setExpandsSelectedPaths */
*** 1202,1214 **** * begin a drag and drop operation by calling {@code exportAsDrag} on the * tree's {@code TransferHandler}. * * @param b whether or not to enable automatic drag handling * @exception HeadlessException if ! * <code>b</code> is <code>true</code> and ! * <code>GraphicsEnvironment.isHeadless()</code> ! * returns <code>true</code> * @see java.awt.GraphicsEnvironment#isHeadless * @see #getDragEnabled * @see #setTransferHandler * @see TransferHandler * @since 1.4 --- 1202,1214 ---- * begin a drag and drop operation by calling {@code exportAsDrag} on the * tree's {@code TransferHandler}. * * @param b whether or not to enable automatic drag handling * @exception HeadlessException if ! * {@code b} is {@code true} and ! * {@code GraphicsEnvironment.isHeadless()} ! * returns {@code true} * @see java.awt.GraphicsEnvironment#isHeadless * @see #getDragEnabled * @see #setTransferHandler * @see TransferHandler * @since 1.4
*** 1239,1268 **** return dragEnabled; } /** * Sets the drop mode for this component. For backward compatibility, ! * the default for this property is <code>DropMode.USE_SELECTION</code>. * Usage of one of the other modes is recommended, however, for an ! * improved user experience. <code>DropMode.ON</code>, for instance, * offers similar behavior of showing items as selected, but does so without * affecting the actual selection in the tree. * <p> ! * <code>JTree</code> supports the following drop modes: * <ul> ! * <li><code>DropMode.USE_SELECTION</code></li> ! * <li><code>DropMode.ON</code></li> ! * <li><code>DropMode.INSERT</code></li> ! * <li><code>DropMode.ON_OR_INSERT</code></li> * </ul> * <p> * The drop mode is only meaningful if this component has a ! * <code>TransferHandler</code> that accepts drops. * * @param dropMode the drop mode to use * @throws IllegalArgumentException if the drop mode is unsupported ! * or <code>null</code> * @see #getDropMode * @see #getDropLocation * @see #setTransferHandler * @see TransferHandler * @since 1.6 --- 1239,1268 ---- return dragEnabled; } /** * Sets the drop mode for this component. For backward compatibility, ! * the default for this property is {@code DropMode.USE_SELECTION}. * Usage of one of the other modes is recommended, however, for an ! * improved user experience. {@code DropMode.ON}, for instance, * offers similar behavior of showing items as selected, but does so without * affecting the actual selection in the tree. * <p> ! * {@code JTree} supports the following drop modes: * <ul> ! * <li>{@code DropMode.USE_SELECTION}</li> ! * <li>{@code DropMode.ON}</li> ! * <li>{@code DropMode.INSERT}</li> ! * <li>{@code DropMode.ON_OR_INSERT}</li> * </ul> * <p> * The drop mode is only meaningful if this component has a ! * {@code TransferHandler} that accepts drops. * * @param dropMode the drop mode to use * @throws IllegalArgumentException if the drop mode is unsupported ! * or {@code null} * @see #getDropMode * @see #getDropLocation * @see #setTransferHandler * @see TransferHandler * @since 1.6
*** 1301,1311 **** /** * Calculates a drop location in this component, representing where a * drop at the given point should insert data. * * @param p the point to calculate a drop location for ! * @return the drop location, or <code>null</code> */ DropLocation dropLocationForPoint(Point p) { DropLocation location = null; int row = getClosestRowForLocation(p.x, p.y); --- 1301,1311 ---- /** * Calculates a drop location in this component, representing where a * drop at the given point should insert data. * * @param p the point to calculate a drop location for ! * @return the drop location, or {@code null} */ DropLocation dropLocationForPoint(Point p) { DropLocation location = null; int row = getClosestRowForLocation(p.x, p.y);
*** 1423,1446 **** * a drop index). It can return a state object to the caller encapsulating * any saved selection state. On a second call, let's say the drop location * is being changed to something else. The component doesn't need to * restore anything yet, so it simply passes back the same state object * to have the DnD system continue storing it. Finally, let's say this ! * method is messaged with <code>null</code>. This means DnD * is finished with this component for now, meaning it should restore * state. At this point, it can use the state parameter to restore ! * said state, and of course return <code>null</code> since there's * no longer anything to store. * * @param location the drop location (as calculated by ! * <code>dropLocationForPoint</code>) or <code>null</code> * if there's no longer a valid drop location * @param state the state object saved earlier for this component, ! * or <code>null</code> * @param forDrop whether or not the method is being called because an * actual drop occurred ! * @return any saved state for this component, or <code>null</code> if none */ Object setDropLocation(TransferHandler.DropLocation location, Object state, boolean forDrop) { --- 1423,1446 ---- * a drop index). It can return a state object to the caller encapsulating * any saved selection state. On a second call, let's say the drop location * is being changed to something else. The component doesn't need to * restore anything yet, so it simply passes back the same state object * to have the DnD system continue storing it. Finally, let's say this ! * method is messaged with {@code null}. This means DnD * is finished with this component for now, meaning it should restore * state. At this point, it can use the state parameter to restore ! * said state, and of course return {@code null} since there's * no longer anything to store. * * @param location the drop location (as calculated by ! * {@code dropLocationForPoint}) or {@code null} * if there's no longer a valid drop location * @param state the state object saved earlier for this component, ! * or {@code null} * @param forDrop whether or not the method is being called because an * actual drop occurred ! * @return any saved state for this component, or {@code null} if none */ Object setDropLocation(TransferHandler.DropLocation location, Object state, boolean forDrop) {
*** 1492,1502 **** * as the drop location during a DnD operation over the component, * or {@code null} if no location is to currently be shown. * <p> * This method is not meant for querying the drop location * from a {@code TransferHandler}, as the drop location is only ! * set after the {@code TransferHandler}'s <code>canImport</code> * has returned and has allowed for the location to be shown. * <p> * When this property changes, a property change event with * name "dropLocation" is fired by the component. * --- 1492,1502 ---- * as the drop location during a DnD operation over the component, * or {@code null} if no location is to currently be shown. * <p> * This method is not meant for querying the drop location * from a {@code TransferHandler}, as the drop location is only ! * set after the {@code TransferHandler}'s {@code canImport} * has returned and has allowed for the location to be shown. * <p> * When this property changes, a property change event with * name "dropLocation" is fired by the component. *
*** 1522,1532 **** dropTimer.stop(); } } /** ! * Returns <code>isEditable</code>. This is invoked from the UI before * editing begins to insure that the given path can be edited. This * is provided as an entry point for subclassers to add filtered * editing without having to resort to creating a new editor. * * @param path a {@code TreePath} identifying a node --- 1522,1532 ---- dropTimer.stop(); } } /** ! * Returns {@code isEditable}. This is invoked from the UI before * editing begins to insure that the given path can be edited. This * is provided as an entry point for subclassers to add filtered * editing without having to resort to creating a new editor. * * @param path a {@code TreePath} identifying a node
*** 1536,1559 **** public boolean isPathEditable(TreePath path) { return isEditable(); } /** ! * Overrides <code>JComponent</code>'s <code>getToolTipText</code> * method in order to allow * renderer's tips to be used if it has text set. * <p> ! * NOTE: For <code>JTree</code> to properly display tooltips of its ! * renderers, <code>JTree</code> must be a registered component with the ! * <code>ToolTipManager</code>. This can be done by invoking ! * <code>ToolTipManager.sharedInstance().registerComponent(tree)</code>. * This is not done automatically! * ! * @param event the <code>MouseEvent</code> that initiated the ! * <code>ToolTip</code> display ! * @return a string containing the tooltip or <code>null</code> ! * if <code>event</code> is null */ public String getToolTipText(MouseEvent event) { String tip = null; if(event != null) { --- 1536,1559 ---- public boolean isPathEditable(TreePath path) { return isEditable(); } /** ! * Overrides {@code JComponent}'s {@code getToolTipText} * method in order to allow * renderer's tips to be used if it has text set. * <p> ! * NOTE: For {@code JTree} to properly display tooltips of its ! * renderers, {@code JTree} must be a registered component with the ! * {@code ToolTipManager}. This can be done by invoking ! * {@code ToolTipManager.sharedInstance().registerComponent(tree)}. * This is not done automatically! * ! * @param event the {@code MouseEvent} that initiated the ! * {@code ToolTip} display ! * @return a string containing the tooltip or {@code null} ! * if {@code event} is null */ public String getToolTipText(MouseEvent event) { String tip = null; if(event != null) {
*** 1595,1616 **** return tip; } /** * Called by the renderers to convert the specified value to ! * text. This implementation returns <code>value.toString</code>, ignoring * all other arguments. To control the conversion, subclass this * method and use any of the arguments you need. * ! * @param value the <code>Object</code> to convert to text * @param selected true if the node is selected * @param expanded true if the node is expanded * @param leaf true if the node is a leaf node * @param row an integer specifying the node's display row, where 0 is * the first row in the display * @param hasFocus true if the node has the focus ! * @return the <code>String</code> representation of the node's value */ public String convertValueToText(Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { if(value != null) { --- 1595,1616 ---- return tip; } /** * Called by the renderers to convert the specified value to ! * text. This implementation returns {@code value.toString}, ignoring * all other arguments. To control the conversion, subclass this * method and use any of the arguments you need. * ! * @param value the {@code Object} to convert to text * @param selected true if the node is selected * @param expanded true if the node is expanded * @param leaf true if the node is a leaf node * @param row an integer specifying the node's display row, where 0 is * the first row in the display * @param hasFocus true if the node has the focus ! * @return the {@code String} representation of the node's value */ public String convertValueToText(Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { if(value != null) {
*** 1644,1678 **** } /** * Selects the node identified by the specified path. If any * component of the path is hidden (under a collapsed node), and ! * <code>getExpandsSelectedPaths</code> is true it is * exposed (made viewable). * ! * @param path the <code>TreePath</code> specifying the node to select */ public void setSelectionPath(TreePath path) { getSelectionModel().setSelectionPath(path); } /** * Selects the nodes identified by the specified array of paths. * If any component in any of the paths is hidden (under a collapsed ! * node), and <code>getExpandsSelectedPaths</code> is true * it is exposed (made viewable). * ! * @param paths an array of <code>TreePath</code> objects that specifies * the nodes to select */ public void setSelectionPaths(TreePath[] paths) { getSelectionModel().setSelectionPaths(paths); } /** * Sets the path identifies as the lead. The lead may not be selected. ! * The lead is not maintained by <code>JTree</code>, * rather the UI will update it. * <p> * This is a bound property. * * @param newPath the new lead path --- 1644,1678 ---- } /** * Selects the node identified by the specified path. If any * component of the path is hidden (under a collapsed node), and ! * {@code getExpandsSelectedPaths} is true it is * exposed (made viewable). * ! * @param path the {@code TreePath} specifying the node to select */ public void setSelectionPath(TreePath path) { getSelectionModel().setSelectionPath(path); } /** * Selects the nodes identified by the specified array of paths. * If any component in any of the paths is hidden (under a collapsed ! * node), and {@code getExpandsSelectedPaths} is true * it is exposed (made viewable). * ! * @param paths an array of {@code TreePath} objects that specifies * the nodes to select */ public void setSelectionPaths(TreePath[] paths) { getSelectionModel().setSelectionPaths(paths); } /** * Sets the path identifies as the lead. The lead may not be selected. ! * The lead is not maintained by {@code JTree}, * rather the UI will update it. * <p> * This is a bound property. * * @param newPath the new lead path
*** 1696,1706 **** } } /** * Sets the path identified as the anchor. ! * The anchor is not maintained by <code>JTree</code>, rather the UI will * update it. * <p> * This is a bound property. * * @param newPath the new anchor path --- 1696,1706 ---- } } /** * Sets the path identified as the anchor. ! * The anchor is not maintained by {@code JTree}, rather the UI will * update it. * <p> * This is a bound property. * * @param newPath the new anchor path
*** 1728,1742 **** setSelectionRows(rows); } /** * Selects the nodes corresponding to each of the specified rows ! * in the display. If a particular element of <code>rows</code> is ! * &lt; 0 or &gt;= <code>getRowCount</code>, it will be ignored. * If none of the elements ! * in <code>rows</code> are valid rows, the selection will ! * be cleared. That is it will be as if <code>clearSelection</code> * was invoked. * * @param rows an array of ints specifying the rows to select, * where 0 indicates the first row in the display */ --- 1728,1742 ---- setSelectionRows(rows); } /** * Selects the nodes corresponding to each of the specified rows ! * in the display. If a particular element of {@code rows} is ! * &lt; 0 or &gt;= {@code getRowCount}, it will be ignored. * If none of the elements ! * in {@code rows} are valid rows, the selection will ! * be cleared. That is it will be as if {@code clearSelection} * was invoked. * * @param rows an array of ints specifying the rows to select, * where 0 indicates the first row in the display */
*** 1753,1788 **** setSelectionPaths(paths); } } /** ! * Adds the node identified by the specified <code>TreePath</code> * to the current selection. If any component of the path isn't ! * viewable, and <code>getExpandsSelectedPaths</code> is true it is * made viewable. * <p> ! * Note that <code>JTree</code> does not allow duplicate nodes to * exist as children under the same parent -- each sibling must be * a unique object. * ! * @param path the <code>TreePath</code> to add */ public void addSelectionPath(TreePath path) { getSelectionModel().addSelectionPath(path); } /** * Adds each path in the array of paths to the current selection. If * any component of any of the paths isn't viewable and ! * <code>getExpandsSelectedPaths</code> is true, it is * made viewable. * <p> ! * Note that <code>JTree</code> does not allow duplicate nodes to * exist as children under the same parent -- each sibling must be * a unique object. * ! * @param paths an array of <code>TreePath</code> objects that specifies * the nodes to add */ public void addSelectionPaths(TreePath[] paths) { getSelectionModel().addSelectionPaths(paths); } --- 1753,1788 ---- setSelectionPaths(paths); } } /** ! * Adds the node identified by the specified {@code TreePath} * to the current selection. If any component of the path isn't ! * viewable, and {@code getExpandsSelectedPaths} is true it is * made viewable. * <p> ! * Note that {@code JTree} does not allow duplicate nodes to * exist as children under the same parent -- each sibling must be * a unique object. * ! * @param path the {@code TreePath} to add */ public void addSelectionPath(TreePath path) { getSelectionModel().addSelectionPath(path); } /** * Adds each path in the array of paths to the current selection. If * any component of any of the paths isn't viewable and ! * {@code getExpandsSelectedPaths} is true, it is * made viewable. * <p> ! * Note that {@code JTree} does not allow duplicate nodes to * exist as children under the same parent -- each sibling must be * a unique object. * ! * @param paths an array of {@code TreePath} objects that specifies * the nodes to add */ public void addSelectionPaths(TreePath[] paths) { getSelectionModel().addSelectionPaths(paths); }
*** 1823,1833 **** * a convenience method for * {@code getSelectionModel().getSelectionPath().getLastPathComponent()}. * This is typically only useful if the selection has one path. * * @return the last path component of the selected path, or ! * <code>null</code> if nothing is selected * @see TreePath#getLastPathComponent */ public Object getLastSelectedPathComponent() { TreePath selPath = getSelectionModel().getSelectionPath(); --- 1823,1833 ---- * a convenience method for * {@code getSelectionModel().getSelectionPath().getLastPathComponent()}. * This is typically only useful if the selection has one path. * * @return the last path component of the selected path, or ! * {@code null} if nothing is selected * @see TreePath#getLastPathComponent */ public Object getLastSelectedPathComponent() { TreePath selPath = getSelectionModel().getSelectionPath();
*** 1854,1887 **** } /** * Returns the path to the first selected node. * ! * @return the <code>TreePath</code> for the first selected node, ! * or <code>null</code> if nothing is currently selected */ public TreePath getSelectionPath() { return getSelectionModel().getSelectionPath(); } /** * Returns the paths of all selected values. * ! * @return an array of <code>TreePath</code> objects indicating the selected ! * nodes, or <code>null</code> if nothing is currently selected */ public TreePath[] getSelectionPaths() { TreePath[] selectionPaths = getSelectionModel().getSelectionPaths(); return (selectionPaths != null && selectionPaths.length > 0) ? selectionPaths : null; } /** * Returns all of the currently selected rows. This method is simply ! * forwarded to the <code>TreeSelectionModel</code>. ! * If nothing is selected <code>null</code> or an empty array will ! * be returned, based on the <code>TreeSelectionModel</code> * implementation. * * @return an array of integers that identifies all currently selected rows * where 0 is the first row in the display */ --- 1854,1887 ---- } /** * Returns the path to the first selected node. * ! * @return the {@code TreePath} for the first selected node, ! * or {@code null} if nothing is currently selected */ public TreePath getSelectionPath() { return getSelectionModel().getSelectionPath(); } /** * Returns the paths of all selected values. * ! * @return an array of {@code TreePath} objects indicating the selected ! * nodes, or {@code null} if nothing is currently selected */ public TreePath[] getSelectionPaths() { TreePath[] selectionPaths = getSelectionModel().getSelectionPaths(); return (selectionPaths != null && selectionPaths.length > 0) ? selectionPaths : null; } /** * Returns all of the currently selected rows. This method is simply ! * forwarded to the {@code TreeSelectionModel}. ! * If nothing is selected {@code null} or an empty array will ! * be returned, based on the {@code TreeSelectionModel} * implementation. * * @return an array of integers that identifies all currently selected rows * where 0 is the first row in the display */
*** 1921,1931 **** /** * Returns the row index corresponding to the lead path. * * @return an integer giving the row index of the lead path, * where 0 is the first row in the display; or -1 ! * if <code>leadPath</code> is <code>null</code> */ public int getLeadSelectionRow() { TreePath leadPath = getLeadSelectionPath(); if (leadPath != null) { --- 1921,1931 ---- /** * Returns the row index corresponding to the lead path. * * @return an integer giving the row index of the lead path, * where 0 is the first row in the display; or -1 ! * if {@code leadPath} is {@code null} */ public int getLeadSelectionRow() { TreePath leadPath = getLeadSelectionPath(); if (leadPath != null) {
*** 1935,1945 **** } /** * Returns true if the item identified by the path is currently selected. * ! * @param path a <code>TreePath</code> identifying a node * @return true if the node is selected */ public boolean isPathSelected(TreePath path) { return getSelectionModel().isPathSelected(path); } --- 1935,1945 ---- } /** * Returns true if the item identified by the path is currently selected. * ! * @param path a {@code TreePath} identifying a node * @return true if the node is selected */ public boolean isPathSelected(TreePath path) { return getSelectionModel().isPathSelected(path); }
*** 1954,1976 **** public boolean isRowSelected(int row) { return getSelectionModel().isRowSelected(row); } /** ! * Returns an <code>Enumeration</code> of the descendants of the ! * path <code>parent</code> that ! * are currently expanded. If <code>parent</code> is not currently ! * expanded, this will return <code>null</code>. * If you expand/collapse nodes while ! * iterating over the returned <code>Enumeration</code> * this may not return all * the expanded paths, or may return paths that are no longer expanded. * * @param parent the path which is to be examined ! * @return an <code>Enumeration</code> of the descendents of ! * <code>parent</code>, or <code>null</code> if ! * <code>parent</code> is not currently expanded */ public Enumeration<TreePath> getExpandedDescendants(TreePath parent) { if(!isExpanded(parent)) return null; --- 1954,1976 ---- public boolean isRowSelected(int row) { return getSelectionModel().isRowSelected(row); } /** ! * Returns an {@code Enumeration} of the descendants of the ! * path {@code parent} that ! * are currently expanded. If {@code parent} is not currently ! * expanded, this will return {@code null}. * If you expand/collapse nodes while ! * iterating over the returned {@code Enumeration} * this may not return all * the expanded paths, or may return paths that are no longer expanded. * * @param parent the path which is to be examined ! * @return an {@code Enumeration} of the descendents of ! * {@code parent}, or {@code null} if ! * {@code parent} is not currently expanded */ public Enumeration<TreePath> getExpandedDescendants(TreePath parent) { if(!isExpanded(parent)) return null;
*** 2006,2025 **** /** * Returns true if the node identified by the path has ever been * expanded. * * @param path a {@code TreePath} identifying a node ! * @return true if the <code>path</code> has ever been expanded */ public boolean hasBeenExpanded(TreePath path) { return (path != null && expandedState.get(path) != null); } /** * Returns true if the node identified by the path is currently expanded, * ! * @param path the <code>TreePath</code> specifying the node to check * @return false if any of the nodes in the node's path are collapsed, * true if all nodes in the path are expanded */ public boolean isExpanded(TreePath path) { --- 2006,2025 ---- /** * Returns true if the node identified by the path has ever been * expanded. * * @param path a {@code TreePath} identifying a node ! * @return true if the {@code path} has ever been expanded */ public boolean hasBeenExpanded(TreePath path) { return (path != null && expandedState.get(path) != null); } /** * Returns true if the node identified by the path is currently expanded, * ! * @param path the {@code TreePath} specifying the node to check * @return false if any of the nodes in the node's path are collapsed, * true if all nodes in the path are expanded */ public boolean isExpanded(TreePath path) {
*** 2062,2072 **** /** * Returns true if the value identified by path is currently collapsed, * this will return false if any of the values in path are currently * not being displayed. * ! * @param path the <code>TreePath</code> to check * @return true if any of the nodes in the node's path are collapsed, * false if all nodes in the path are expanded */ public boolean isCollapsed(TreePath path) { return !isExpanded(path); --- 2062,2072 ---- /** * Returns true if the value identified by path is currently collapsed, * this will return false if any of the values in path are currently * not being displayed. * ! * @param path the {@code TreePath} to check * @return true if any of the nodes in the node's path are collapsed, * false if all nodes in the path are expanded */ public boolean isCollapsed(TreePath path) { return !isExpanded(path);
*** 2084,2094 **** } /** * Ensures that the node identified by path is currently viewable. * ! * @param path the <code>TreePath</code> to make visible */ public void makeVisible(TreePath path) { if(path != null) { TreePath parentPath = path.getParentPath(); --- 2084,2094 ---- } /** * Ensures that the node identified by path is currently viewable. * ! * @param path the {@code TreePath} to make visible */ public void makeVisible(TreePath path) { if(path != null) { TreePath parentPath = path.getParentPath();
*** 2117,2165 **** } return false; } /** ! * Returns the <code>Rectangle</code> that the specified node will be drawn ! * into. Returns <code>null</code> if any component in the path is hidden * (under a collapsed parent). * <p> * Note:<br> * This method returns a valid rectangle, even if the specified * node is not currently displayed. * ! * @param path the <code>TreePath</code> identifying the node ! * @return the <code>Rectangle</code> the node is drawn in, ! * or <code>null</code> */ public Rectangle getPathBounds(TreePath path) { TreeUI tree = getUI(); if(tree != null) return tree.getPathBounds(this, path); return null; } /** ! * Returns the <code>Rectangle</code> that the node at the specified row is * drawn in. * * @param row the row to be drawn, where 0 is the first row in the * display ! * @return the <code>Rectangle</code> the node is drawn in */ public Rectangle getRowBounds(int row) { return getPathBounds(getPathForRow(row)); } /** * Makes sure all the path components in path are expanded (except * for the last path component) and scrolls so that the * node identified by the path is displayed. Only works when this ! * <code>JTree</code> is contained in a <code>JScrollPane</code>. * ! * @param path the <code>TreePath</code> identifying the node to * bring into view */ public void scrollPathToVisible(TreePath path) { if(path != null) { makeVisible(path); --- 2117,2165 ---- } return false; } /** ! * Returns the {@code Rectangle} that the specified node will be drawn ! * into. Returns {@code null} if any component in the path is hidden * (under a collapsed parent). * <p> * Note:<br> * This method returns a valid rectangle, even if the specified * node is not currently displayed. * ! * @param path the {@code TreePath} identifying the node ! * @return the {@code Rectangle} the node is drawn in, ! * or {@code null} */ public Rectangle getPathBounds(TreePath path) { TreeUI tree = getUI(); if(tree != null) return tree.getPathBounds(this, path); return null; } /** ! * Returns the {@code Rectangle} that the node at the specified row is * drawn in. * * @param row the row to be drawn, where 0 is the first row in the * display ! * @return the {@code Rectangle} the node is drawn in */ public Rectangle getRowBounds(int row) { return getPathBounds(getPathForRow(row)); } /** * Makes sure all the path components in path are expanded (except * for the last path component) and scrolls so that the * node identified by the path is displayed. Only works when this ! * {@code JTree} is contained in a {@code JScrollPane}. * ! * @param path the {@code TreePath} identifying the node to * bring into view */ public void scrollPathToVisible(TreePath path) { if(path != null) { makeVisible(path);
*** 2176,2204 **** } /** * Scrolls the item identified by row until it is displayed. The minimum * of amount of scrolling necessary to bring the row into view ! * is performed. Only works when this <code>JTree</code> is contained in a ! * <code>JScrollPane</code>. * * @param row an integer specifying the row to scroll, where 0 is the * first row in the display */ public void scrollRowToVisible(int row) { scrollPathToVisible(getPathForRow(row)); } /** ! * Returns the path for the specified row. If <code>row</code> is ! * not visible, or a {@code TreeUI} has not been set, <code>null</code> * is returned. * * @param row an integer specifying a row ! * @return the <code>TreePath</code> to the specified node, ! * <code>null</code> if <code>row &lt; 0</code> ! * or <code>row &gt;= getRowCount()</code> */ public TreePath getPathForRow(int row) { TreeUI tree = getUI(); if(tree != null) --- 2176,2204 ---- } /** * Scrolls the item identified by row until it is displayed. The minimum * of amount of scrolling necessary to bring the row into view ! * is performed. Only works when this {@code JTree} is contained in a ! * {@code JScrollPane}. * * @param row an integer specifying the row to scroll, where 0 is the * first row in the display */ public void scrollRowToVisible(int row) { scrollPathToVisible(getPathForRow(row)); } /** ! * Returns the path for the specified row. If {@code row} is ! * not visible, or a {@code TreeUI} has not been set, {@code null} * is returned. * * @param row an integer specifying a row ! * @return the {@code TreePath} to the specified node, ! * {@code null} if {@code row < 0} ! * or {@code row >= getRowCount()} */ public TreePath getPathForRow(int row) { TreeUI tree = getUI(); if(tree != null)
*** 2208,2218 **** /** * Returns the row that displays the node identified by the specified * path. * ! * @param path the <code>TreePath</code> identifying a node * @return an integer specifying the display row, where 0 is the first * row in the display, or -1 if any of the elements in path * are hidden under a collapsed parent. */ public int getRowForPath(TreePath path) { --- 2208,2218 ---- /** * Returns the row that displays the node identified by the specified * path. * ! * @param path the {@code TreePath} identifying a node * @return an integer specifying the display row, where 0 is the first * row in the display, or -1 if any of the elements in path * are hidden under a collapsed parent. */ public int getRowForPath(TreePath path) {
*** 2226,2236 **** /** * Ensures that the node identified by the specified path is * expanded and viewable. If the last item in the path is a * leaf, this will have no effect. * ! * @param path the <code>TreePath</code> identifying a node */ public void expandPath(TreePath path) { // Only expand if not leaf! TreeModel model = getModel(); --- 2226,2236 ---- /** * Ensures that the node identified by the specified path is * expanded and viewable. If the last item in the path is a * leaf, this will have no effect. * ! * @param path the {@code TreePath} identifying a node */ public void expandPath(TreePath path) { // Only expand if not leaf! TreeModel model = getModel();
*** 2242,2252 **** /** * Ensures that the node in the specified row is expanded and * viewable. * <p> ! * If <code>row</code> is &lt; 0 or &gt;= <code>getRowCount</code> this * will have no effect. * * @param row an integer specifying a display row, where 0 is the * first row in the display */ --- 2242,2252 ---- /** * Ensures that the node in the specified row is expanded and * viewable. * <p> ! * If {@code row} is {@code < 0} or {@code >= getRowCount} this * will have no effect. * * @param row an integer specifying a display row, where 0 is the * first row in the display */
*** 2256,2275 **** /** * Ensures that the node identified by the specified path is * collapsed and viewable. * ! * @param path the <code>TreePath</code> identifying a node */ public void collapsePath(TreePath path) { setExpandedState(path, false); } /** * Ensures that the node in the specified row is collapsed. * <p> ! * If <code>row</code> is &lt; 0 or &gt;= <code>getRowCount</code> this * will have no effect. * * @param row an integer specifying a display row, where 0 is the * first row in the display */ --- 2256,2275 ---- /** * Ensures that the node identified by the specified path is * collapsed and viewable. * ! * @param path the {@code TreePath} identifying a node */ public void collapsePath(TreePath path) { setExpandedState(path, false); } /** * Ensures that the node in the specified row is collapsed. * <p> ! * If {@code row} is {@code < 0} or {@code >= getRowCount} this * will have no effect. * * @param row an integer specifying a display row, where 0 is the * first row in the display */
*** 2282,2292 **** * * @param x an integer giving the number of pixels horizontally from * the left edge of the display area, minus any left margin * @param y an integer giving the number of pixels vertically from * the top of the display area, minus any top margin ! * @return the <code>TreePath</code> for the node at that location */ public TreePath getPathForLocation(int x, int y) { TreePath closestPath = getClosestPathForLocation(x, y); if(closestPath != null) { --- 2282,2292 ---- * * @param x an integer giving the number of pixels horizontally from * the left edge of the display area, minus any left margin * @param y an integer giving the number of pixels vertically from * the top of the display area, minus any top margin ! * @return the {@code TreePath} for the node at that location */ public TreePath getPathForLocation(int x, int y) { TreePath closestPath = getClosestPathForLocation(x, y); if(closestPath != null) {
*** 2316,2335 **** } /** * Returns the path to the node that is closest to x,y. If * no nodes are currently viewable, or there is no model, returns ! * <code>null</code>, otherwise it always returns a valid path. To test if * the node is exactly at x, y, get the node's bounds and * test x, y against that. * * @param x an integer giving the number of pixels horizontally from * the left edge of the display area, minus any left margin * @param y an integer giving the number of pixels vertically from * the top of the display area, minus any top margin ! * @return the <code>TreePath</code> for the node closest to that location, ! * <code>null</code> if nothing is viewable or there is no model * * @see #getPathForLocation * @see #getPathBounds */ public TreePath getClosestPathForLocation(int x, int y) { --- 2316,2335 ---- } /** * Returns the path to the node that is closest to x,y. If * no nodes are currently viewable, or there is no model, returns ! * {@code null}, otherwise it always returns a valid path. To test if * the node is exactly at x, y, get the node's bounds and * test x, y against that. * * @param x an integer giving the number of pixels horizontally from * the left edge of the display area, minus any left margin * @param y an integer giving the number of pixels vertically from * the top of the display area, minus any top margin ! * @return the {@code TreePath} for the node closest to that location, ! * {@code null} if nothing is viewable or there is no model * * @see #getPathForLocation * @see #getPathBounds */ public TreePath getClosestPathForLocation(int x, int y) {
*** 2361,2371 **** return getRowForPath(getClosestPathForLocation(x, y)); } /** * Returns true if the tree is being edited. The item that is being ! * edited can be obtained using <code>getSelectionPath</code>. * * @return true if the user is currently editing a node * @see #getSelectionPath */ public boolean isEditing() { --- 2361,2371 ---- return getRowForPath(getClosestPathForLocation(x, y)); } /** * Returns true if the tree is being edited. The item that is being ! * edited can be obtained using {@code getSelectionPath}. * * @return true if the user is currently editing a node * @see #getSelectionPath */ public boolean isEditing() {
*** 2376,2386 **** return false; } /** * Ends the current editing session. ! * (The <code>DefaultTreeCellEditor</code> * object saves any edits that are currently in progress on a cell. * Other implementations may operate differently.) * Has no effect if the tree isn't being edited. * <blockquote> * <b>Note:</b><br> --- 2376,2386 ---- return false; } /** * Ends the current editing session. ! * (The {@code DefaultTreeCellEditor} * object saves any edits that are currently in progress on a cell. * Other implementations may operate differently.) * Has no effect if the tree isn't being edited. * <blockquote> * <b>Note:</b><br>
*** 2410,2424 **** tree.cancelEditing(this); } /** * Selects the node identified by the specified path and initiates ! * editing. The edit-attempt fails if the <code>CellEditor</code> * does not allow * editing for the specified item. * ! * @param path the <code>TreePath</code> identifying a node */ public void startEditingAtPath(TreePath path) { TreeUI tree = getUI(); if(tree != null) --- 2410,2424 ---- tree.cancelEditing(this); } /** * Selects the node identified by the specified path and initiates ! * editing. The edit-attempt fails if the {@code CellEditor} * does not allow * editing for the specified item. * ! * @param path the {@code TreePath} identifying a node */ public void startEditingAtPath(TreePath path) { TreeUI tree = getUI(); if(tree != null)
*** 2426,2436 **** } /** * Returns the path to the element that is currently being edited. * ! * @return the <code>TreePath</code> for the node being edited */ public TreePath getEditingPath() { TreeUI tree = getUI(); if(tree != null) --- 2426,2436 ---- } /** * Returns the path to the element that is currently being edited. * ! * @return the {@code TreePath} for the node being edited */ public TreePath getEditingPath() { TreeUI tree = getUI(); if(tree != null)
*** 2446,2463 **** // Since row based selections require a UI many of these won't work // without one. // /** ! * Sets the tree's selection model. When a <code>null</code> value is * specified an empty ! * <code>selectionModel</code> is used, which does not allow selections. * <p> * This is a bound property. * ! * @param selectionModel the <code>TreeSelectionModel</code> to use, ! * or <code>null</code> to disable selections * @see TreeSelectionModel * @beaninfo * bound: true * description: The tree's selection model. */ --- 2446,2463 ---- // Since row based selections require a UI many of these won't work // without one. // /** ! * Sets the tree's selection model. When a {@code null} value is * specified an empty ! * {@code selectionModel} is used, which does not allow selections. * <p> * This is a bound property. * ! * @param selectionModel the {@code TreeSelectionModel} to use, ! * or {@code null} to disable selections * @see TreeSelectionModel * @beaninfo * bound: true * description: The tree's selection model. */
*** 2490,2502 **** } } /** * Returns the model for selections. This should always return a ! * non-<code>null</code> value. If you don't want to allow anything * to be selected ! * set the selection model to <code>null</code>, which forces an empty * selection model to be used. * * @return the model for selections * @see #setSelectionModel */ --- 2490,2502 ---- } } /** * Returns the model for selections. This should always return a ! * non-{@code null} value. If you don't want to allow anything * to be selected ! * set the selection model to {@code null}, which forces an empty * selection model to be used. * * @return the model for selections * @see #setSelectionModel */
*** 2637,2665 **** /** * Removes the node identified by the specified path from the current * selection. * ! * @param path the <code>TreePath</code> identifying a node */ public void removeSelectionPath(TreePath path) { this.getSelectionModel().removeSelectionPath(path); } /** * Removes the nodes identified by the specified paths from the * current selection. * ! * @param paths an array of <code>TreePath</code> objects that * specifies the nodes to remove */ public void removeSelectionPaths(TreePath[] paths) { this.getSelectionModel().removeSelectionPaths(paths); } /** ! * Removes the row at the index <code>row</code> from the current * selection. * * @param row the row to remove */ public void removeSelectionRow(int row) { --- 2637,2665 ---- /** * Removes the node identified by the specified path from the current * selection. * ! * @param path the {@code TreePath} identifying a node */ public void removeSelectionPath(TreePath path) { this.getSelectionModel().removeSelectionPath(path); } /** * Removes the nodes identified by the specified paths from the * current selection. * ! * @param paths an array of {@code TreePath} objects that * specifies the nodes to remove */ public void removeSelectionPaths(TreePath[] paths) { this.getSelectionModel().removeSelectionPaths(paths); } /** ! * Removes the row at the index {@code row} from the current * selection. * * @param row the row to remove */ public void removeSelectionRow(int row) {
*** 2703,2713 **** public boolean isSelectionEmpty() { return getSelectionModel().isSelectionEmpty(); } /** ! * Adds a listener for <code>TreeExpansion</code> events. * * @param tel a TreeExpansionListener that will be notified when * a tree node is expanded or collapsed (a "negative * expansion") */ --- 2703,2713 ---- public boolean isSelectionEmpty() { return getSelectionModel().isSelectionEmpty(); } /** ! * Adds a listener for {@code TreeExpansion} events. * * @param tel a TreeExpansionListener that will be notified when * a tree node is expanded or collapsed (a "negative * expansion") */
*** 2717,2787 **** } listenerList.add(TreeExpansionListener.class, tel); } /** ! * Removes a listener for <code>TreeExpansion</code> events. * ! * @param tel the <code>TreeExpansionListener</code> to remove */ public void removeTreeExpansionListener(TreeExpansionListener tel) { listenerList.remove(TreeExpansionListener.class, tel); if (uiTreeExpansionListener == tel) { uiTreeExpansionListener = null; } } /** ! * Returns an array of all the <code>TreeExpansionListener</code>s added * to this JTree with addTreeExpansionListener(). * ! * @return all of the <code>TreeExpansionListener</code>s added or an empty * array if no listeners have been added * @since 1.4 */ public TreeExpansionListener[] getTreeExpansionListeners() { return listenerList.getListeners(TreeExpansionListener.class); } /** ! * Adds a listener for <code>TreeWillExpand</code> events. * ! * @param tel a <code>TreeWillExpandListener</code> that will be notified * when a tree node will be expanded or collapsed (a "negative * expansion") */ public void addTreeWillExpandListener(TreeWillExpandListener tel) { listenerList.add(TreeWillExpandListener.class, tel); } /** ! * Removes a listener for <code>TreeWillExpand</code> events. * ! * @param tel the <code>TreeWillExpandListener</code> to remove */ public void removeTreeWillExpandListener(TreeWillExpandListener tel) { listenerList.remove(TreeWillExpandListener.class, tel); } /** ! * Returns an array of all the <code>TreeWillExpandListener</code>s added * to this JTree with addTreeWillExpandListener(). * ! * @return all of the <code>TreeWillExpandListener</code>s added or an empty * array if no listeners have been added * @since 1.4 */ public TreeWillExpandListener[] getTreeWillExpandListeners() { return listenerList.getListeners(TreeWillExpandListener.class); } /** * Notifies all listeners that have registered interest for * notification on this event type. The event instance ! * is lazily created using the <code>path</code> parameter. * ! * @param path the <code>TreePath</code> indicating the node that was * expanded * @see EventListenerList */ public void fireTreeExpanded(TreePath path) { // Guaranteed to return a non-null array --- 2717,2787 ---- } listenerList.add(TreeExpansionListener.class, tel); } /** ! * Removes a listener for {@code TreeExpansion} events. * ! * @param tel the {@code TreeExpansionListener} to remove */ public void removeTreeExpansionListener(TreeExpansionListener tel) { listenerList.remove(TreeExpansionListener.class, tel); if (uiTreeExpansionListener == tel) { uiTreeExpansionListener = null; } } /** ! * Returns an array of all the {@code TreeExpansionListener}s added * to this JTree with addTreeExpansionListener(). * ! * @return all of the {@code TreeExpansionListener}s added or an empty * array if no listeners have been added * @since 1.4 */ public TreeExpansionListener[] getTreeExpansionListeners() { return listenerList.getListeners(TreeExpansionListener.class); } /** ! * Adds a listener for {@code TreeWillExpand} events. * ! * @param tel a {@code TreeWillExpandListener} that will be notified * when a tree node will be expanded or collapsed (a "negative * expansion") */ public void addTreeWillExpandListener(TreeWillExpandListener tel) { listenerList.add(TreeWillExpandListener.class, tel); } /** ! * Removes a listener for {@code TreeWillExpand} events. * ! * @param tel the {@code TreeWillExpandListener} to remove */ public void removeTreeWillExpandListener(TreeWillExpandListener tel) { listenerList.remove(TreeWillExpandListener.class, tel); } /** ! * Returns an array of all the {@code TreeWillExpandListener}s added * to this JTree with addTreeWillExpandListener(). * ! * @return all of the {@code TreeWillExpandListener}s added or an empty * array if no listeners have been added * @since 1.4 */ public TreeWillExpandListener[] getTreeWillExpandListeners() { return listenerList.getListeners(TreeWillExpandListener.class); } /** * Notifies all listeners that have registered interest for * notification on this event type. The event instance ! * is lazily created using the {@code path} parameter. * ! * @param path the {@code TreePath} indicating the node that was * expanded * @see EventListenerList */ public void fireTreeExpanded(TreePath path) { // Guaranteed to return a non-null array
*** 2806,2818 **** } /** * Notifies all listeners that have registered interest for * notification on this event type. The event instance ! * is lazily created using the <code>path</code> parameter. * ! * @param path the <code>TreePath</code> indicating the node that was * collapsed * @see EventListenerList */ public void fireTreeCollapsed(TreePath path) { // Guaranteed to return a non-null array --- 2806,2818 ---- } /** * Notifies all listeners that have registered interest for * notification on this event type. The event instance ! * is lazily created using the {@code path} parameter. * ! * @param path the {@code TreePath} indicating the node that was * collapsed * @see EventListenerList */ public void fireTreeCollapsed(TreePath path) { // Guaranteed to return a non-null array
*** 2837,2849 **** } /** * Notifies all listeners that have registered interest for * notification on this event type. The event instance ! * is lazily created using the <code>path</code> parameter. * ! * @param path the <code>TreePath</code> indicating the node that was * expanded * @throws ExpandVetoException if the expansion is prevented from occurring * @see EventListenerList */ public void fireTreeWillExpand(TreePath path) throws ExpandVetoException { --- 2837,2849 ---- } /** * Notifies all listeners that have registered interest for * notification on this event type. The event instance ! * is lazily created using the {@code path} parameter. * ! * @param path the {@code TreePath} indicating the node that was * expanded * @throws ExpandVetoException if the expansion is prevented from occurring * @see EventListenerList */ public void fireTreeWillExpand(TreePath path) throws ExpandVetoException {
*** 2864,2876 **** } /** * Notifies all listeners that have registered interest for * notification on this event type. The event instance ! * is lazily created using the <code>path</code> parameter. * ! * @param path the <code>TreePath</code> indicating the node that was * expanded * @throws ExpandVetoException if the collapse is prevented from occurring * @see EventListenerList */ public void fireTreeWillCollapse(TreePath path) throws ExpandVetoException { --- 2864,2876 ---- } /** * Notifies all listeners that have registered interest for * notification on this event type. The event instance ! * is lazily created using the {@code path} parameter. * ! * @param path the {@code TreePath} indicating the node that was * expanded * @throws ExpandVetoException if the collapse is prevented from occurring * @see EventListenerList */ public void fireTreeWillCollapse(TreePath path) throws ExpandVetoException {
*** 2889,2901 **** } } } /** ! * Adds a listener for <code>TreeSelection</code> events. * ! * @param tsl the <code>TreeSelectionListener</code> that will be notified * when a node is selected or deselected (a "negative * selection") */ public void addTreeSelectionListener(TreeSelectionListener tsl) { listenerList.add(TreeSelectionListener.class,tsl); --- 2889,2901 ---- } } } /** ! * Adds a listener for {@code TreeSelection} events. * ! * @param tsl the {@code TreeSelectionListener} that will be notified * when a node is selected or deselected (a "negative * selection") */ public void addTreeSelectionListener(TreeSelectionListener tsl) { listenerList.add(TreeSelectionListener.class,tsl);
*** 2905,2917 **** selectionModel.addTreeSelectionListener(selectionRedirector); } } /** ! * Removes a <code>TreeSelection</code> listener. * ! * @param tsl the <code>TreeSelectionListener</code> to remove */ public void removeTreeSelectionListener(TreeSelectionListener tsl) { listenerList.remove(TreeSelectionListener.class,tsl); if(listenerList.getListenerCount(TreeSelectionListener.class) == 0 && selectionRedirector != null) { --- 2905,2917 ---- selectionModel.addTreeSelectionListener(selectionRedirector); } } /** ! * Removes a {@code TreeSelection} listener. * ! * @param tsl the {@code TreeSelectionListener} to remove */ public void removeTreeSelectionListener(TreeSelectionListener tsl) { listenerList.remove(TreeSelectionListener.class,tsl); if(listenerList.getListenerCount(TreeSelectionListener.class) == 0 && selectionRedirector != null) {
*** 2920,2933 **** selectionRedirector = null; } } /** ! * Returns an array of all the <code>TreeSelectionListener</code>s added * to this JTree with addTreeSelectionListener(). * ! * @return all of the <code>TreeSelectionListener</code>s added or an empty * array if no listeners have been added * @since 1.4 */ public TreeSelectionListener[] getTreeSelectionListeners() { return listenerList.getListeners(TreeSelectionListener.class); --- 2920,2933 ---- selectionRedirector = null; } } /** ! * Returns an array of all the {@code TreeSelectionListener}s added * to this JTree with addTreeSelectionListener(). * ! * @return all of the {@code TreeSelectionListener}s added or an empty * array if no listeners have been added * @since 1.4 */ public TreeSelectionListener[] getTreeSelectionListeners() { return listenerList.getListeners(TreeSelectionListener.class);
*** 2935,2947 **** /** * Notifies all listeners that have registered interest for * notification on this event type. * ! * @param e the <code>TreeSelectionEvent</code> to be fired; * generated by the ! * <code>TreeSelectionModel</code> * when a node is selected or deselected * @see EventListenerList */ protected void fireValueChanged(TreeSelectionEvent e) { // Guaranteed to return a non-null array --- 2935,2947 ---- /** * Notifies all listeners that have registered interest for * notification on this event type. * ! * @param e the {@code TreeSelectionEvent} to be fired; * generated by the ! * {@code TreeSelectionModel} * when a node is selected or deselected * @see EventListenerList */ protected void fireValueChanged(TreeSelectionEvent e) { // Guaranteed to return a non-null array
*** 2972,2982 **** } /** * Sets the number of rows that are to be displayed. * This will only work if the tree is contained in a ! * <code>JScrollPane</code>, * and will adjust the preferred size and size of that scrollpane. * <p> * This is a bound property. * * @param newCount the number of rows to display --- 2972,2982 ---- } /** * Sets the number of rows that are to be displayed. * This will only work if the tree is contained in a ! * {@code JScrollPane}, * and will adjust the preferred size and size of that scrollpane. * <p> * This is a bound property. * * @param newCount the number of rows to display
*** 3016,3026 **** } /** * Returns the TreePath to the next tree element that * begins with a prefix. To handle the conversion of a ! * <code>TreePath</code> into a String, <code>convertValueToText</code> * is used. * * @param prefix the string to test for a match * @param startingRow the row for starting the search * @param bias the search direction, either --- 3016,3026 ---- } /** * Returns the TreePath to the next tree element that * begins with a prefix. To handle the conversion of a ! * {@code TreePath} into a String, {@code convertValueToText} * is used. * * @param prefix the string to test for a match * @param startingRow the row for starting the search * @param bias the search direction, either
*** 3217,3227 **** return null; } /** * Updates the expanded state of nodes in the tree based on the ! * previously archived state <code>state</code>. */ private void unarchiveExpandedState(Object state) { if(state instanceof Vector) { Vector<?> paths = (Vector)state; --- 3217,3227 ---- return null; } /** * Updates the expanded state of nodes in the tree based on the ! * previously archived state {@code state}. */ private void unarchiveExpandedState(Object state) { if(state instanceof Vector) { Vector<?> paths = (Vector)state;
*** 3238,3250 **** } } /** * Returns an array of integers specifying the indexs of the ! * components in the <code>path</code>. If <code>path</code> is ! * the root, this will return an empty array. If <code>path</code> ! * is <code>null</code>, <code>null</code> will be returned. */ private int[] getModelIndexsForPath(TreePath path) { if(path != null) { TreeModel model = getModel(); int count = path.getPathCount(); --- 3238,3250 ---- } } /** * Returns an array of integers specifying the indexs of the ! * components in the {@code path}. If {@code path} is ! * the root, this will return an empty array. If {@code path} ! * is {@code null}, {@code null} will be returned. */ private int[] getModelIndexsForPath(TreePath path) { if(path != null) { TreeModel model = getModel(); int count = path.getPathCount();
*** 3262,3275 **** } return null; } /** ! * Returns a <code>TreePath</code> created by obtaining the children ! * for each of the indices in <code>indexs</code>. If <code>indexs</code> ! * or the <code>TreeModel</code> is <code>null</code>, it will return ! * <code>null</code>. */ private TreePath getPathForIndexs(int[] indexs) { if(indexs == null) return null; --- 3262,3275 ---- } return null; } /** ! * Returns a {@code TreePath} created by obtaining the children ! * for each of the indices in {@code indexs}. If {@code indexs} ! * or the {@code TreeModel} is {@code null}, it will return ! * {@code null}. */ private TreePath getPathForIndexs(int[] indexs) { if(indexs == null) return null;
*** 3293,3312 **** } return parentPath; } /** ! * <code>EmptySelectionModel</code> is a <code>TreeSelectionModel</code> * that does not allow anything to be selected. * <p> * <strong>Warning:</strong> * Serialized objects of this class will not be compatible with * future Swing releases. The current serialization support is * appropriate for short term storage or RMI between applications running * the same version of Swing. As of 1.4, support for long term storage * of all JavaBeans&trade; ! * has been added to the <code>java.beans</code> package. * Please see {@link java.beans.XMLEncoder}. */ @SuppressWarnings("serial") protected static class EmptySelectionModel extends DefaultTreeSelectionModel --- 3293,3312 ---- } return parentPath; } /** ! * {@code EmptySelectionModel} is a {@code TreeSelectionModel} * that does not allow anything to be selected. * <p> * <strong>Warning:</strong> * Serialized objects of this class will not be compatible with * future Swing releases. The current serialization support is * appropriate for short term storage or RMI between applications running * the same version of Swing. As of 1.4, support for long term storage * of all JavaBeans&trade; ! * has been added to the {@code java.beans} package. * Please see {@link java.beans.XMLEncoder}. */ @SuppressWarnings("serial") protected static class EmptySelectionModel extends DefaultTreeSelectionModel
*** 3414,3446 **** } } /** ! * Handles creating a new <code>TreeSelectionEvent</code> with the ! * <code>JTree</code> as the * source and passing it off to all the listeners. * <p> * <strong>Warning:</strong> * Serialized objects of this class will not be compatible with * future Swing releases. The current serialization support is * appropriate for short term storage or RMI between applications running * the same version of Swing. As of 1.4, support for long term storage * of all JavaBeans&trade; ! * has been added to the <code>java.beans</code> package. * Please see {@link java.beans.XMLEncoder}. */ @SuppressWarnings("serial") protected class TreeSelectionRedirector implements Serializable, TreeSelectionListener { /** ! * Invoked by the <code>TreeSelectionModel</code> when the * selection changes. * ! * @param e the <code>TreeSelectionEvent</code> generated by the ! * <code>TreeSelectionModel</code> */ public void valueChanged(TreeSelectionEvent e) { TreeSelectionEvent newE; newE = (TreeSelectionEvent)e.cloneWithSource(JTree.this); --- 3414,3446 ---- } } /** ! * Handles creating a new {@code TreeSelectionEvent} with the ! * {@code JTree} as the * source and passing it off to all the listeners. * <p> * <strong>Warning:</strong> * Serialized objects of this class will not be compatible with * future Swing releases. The current serialization support is * appropriate for short term storage or RMI between applications running * the same version of Swing. As of 1.4, support for long term storage * of all JavaBeans&trade; ! * has been added to the {@code java.beans} package. * Please see {@link java.beans.XMLEncoder}. */ @SuppressWarnings("serial") protected class TreeSelectionRedirector implements Serializable, TreeSelectionListener { /** ! * Invoked by the {@code TreeSelectionModel} when the * selection changes. * ! * @param e the {@code TreeSelectionEvent} generated by the ! * {@code TreeSelectionModel} */ public void valueChanged(TreeSelectionEvent e) { TreeSelectionEvent newE; newE = (TreeSelectionEvent)e.cloneWithSource(JTree.this);
*** 3451,3465 **** // // Scrollable interface // /** ! * Returns the preferred display size of a <code>JTree</code>. The height is ! * determined from <code>getVisibleRowCount</code> and the width * is the current preferred width. * ! * @return a <code>Dimension</code> object containing the preferred size */ public Dimension getPreferredScrollableViewportSize() { int width = getPreferredSize().width; int visRows = getVisibleRowCount(); int height = -1; --- 3451,3465 ---- // // Scrollable interface // /** ! * Returns the preferred display size of a {@code JTree}. The height is ! * determined from {@code getVisibleRowCount} and the width * is the current preferred width. * ! * @return a {@code Dimension} object containing the preferred size */ public Dimension getPreferredScrollableViewportSize() { int width = getPreferredSize().width; int visRows = getVisibleRowCount(); int height = -1;
*** 3497,3508 **** * the height of the first displayed row that isn't completely in view * or, if it is totally displayed, the height of the next row in the * scrolling direction. * * @param visibleRect the view area visible within the viewport ! * @param orientation either <code>SwingConstants.VERTICAL</code> ! * or <code>SwingConstants.HORIZONTAL</code> * @param direction less than zero to scroll up/left, * greater than zero for down/right * @return the "unit" increment for scrolling in the specified direction * @see JScrollBar#setUnitIncrement(int) */ --- 3497,3508 ---- * the height of the first displayed row that isn't completely in view * or, if it is totally displayed, the height of the next row in the * scrolling direction. * * @param visibleRect the view area visible within the viewport ! * @param orientation either {@code SwingConstants.VERTICAL} ! * or {@code SwingConstants.HORIZONTAL} * @param direction less than zero to scroll up/left, * greater than zero for down/right * @return the "unit" increment for scrolling in the specified direction * @see JScrollBar#setUnitIncrement(int) */
*** 3538,3552 **** } /** * Returns the amount for a block increment, which is the height or ! * width of <code>visibleRect</code>, based on <code>orientation</code>. * * @param visibleRect the view area visible within the viewport ! * @param orientation either <code>SwingConstants.VERTICAL</code> ! * or <code>SwingConstants.HORIZONTAL</code> * @param direction less than zero to scroll up/left, * greater than zero for down/right. * @return the "block" increment for scrolling in the specified direction * @see JScrollBar#setBlockIncrement(int) */ --- 3538,3552 ---- } /** * Returns the amount for a block increment, which is the height or ! * width of {@code visibleRect}, based on {@code orientation}. * * @param visibleRect the view area visible within the viewport ! * @param orientation either {@code SwingConstants.VERTICAL} ! * or {@code SwingConstants.HORIZONTAL} * @param direction less than zero to scroll up/left, * greater than zero for down/right. * @return the "block" increment for scrolling in the specified direction * @see JScrollBar#setBlockIncrement(int) */
*** 3589,3605 **** } return false; } /** ! * Sets the expanded state of this <code>JTree</code>. ! * If <code>state</code> is ! * true, all parents of <code>path</code> and path are marked as ! * expanded. If <code>state</code> is false, all parents of ! * <code>path</code> are marked EXPANDED, but <code>path</code> itself * is marked collapsed.<p> ! * This will fail if a <code>TreeWillExpandListener</code> vetos it. * * @param path a {@code TreePath} identifying a node * @param state if {@code true}, all parents of @{code path} and path are marked as expanded. * Otherwise, all parents of {@code path} are marked EXPANDED, * but {@code path} itself is marked collapsed. --- 3589,3605 ---- } return false; } /** ! * Sets the expanded state of this {@code JTree}. ! * If {@code state} is ! * true, all parents of {@code path} and path are marked as ! * expanded. If {@code state} is false, all parents of ! * {@code path} are marked EXPANDED, but {@code path} itself * is marked collapsed.<p> ! * This will fail if a {@code TreeWillExpandListener} vetos it. * * @param path a {@code TreePath} identifying a node * @param state if {@code true}, all parents of @{code path} and path are marked as expanded. * Otherwise, all parents of {@code path} are marked EXPANDED, * but {@code path} itself is marked collapsed.
*** 3721,3732 **** } return descendants.elements(); } /** ! * Removes any descendants of the <code>TreePaths</code> in ! * <code>toRemove</code> * that have been expanded. * * @param toRemove an enumeration of the paths to remove; a value of * {@code null} is ignored * @throws ClassCastException if {@code toRemove} contains an --- 3721,3732 ---- } return descendants.elements(); } /** ! * Removes any descendants of the {@code TreePaths} in ! * {@code toRemove} * that have been expanded. * * @param toRemove an enumeration of the paths to remove; a value of * {@code null} is ignored * @throws ClassCastException if {@code toRemove} contains an
*** 3750,3770 **** } } /** * Clears the cache of toggled tree paths. This does NOT send out ! * any <code>TreeExpansionListener</code> events. */ protected void clearToggledPaths() { expandedState.clear(); } /** ! * Creates and returns an instance of <code>TreeModelHandler</code>. * The returned * object is responsible for updating the expanded state when the ! * <code>TreeModel</code> changes. * <p> * For more information on what expanded state means, see the * <a href=#jtree_description>JTree description</a> above. * * @return the instance of {@code TreeModelHandler} --- 3750,3770 ---- } } /** * Clears the cache of toggled tree paths. This does NOT send out ! * any {@code TreeExpansionListener} events. */ protected void clearToggledPaths() { expandedState.clear(); } /** ! * Creates and returns an instance of {@code TreeModelHandler}. * The returned * object is responsible for updating the expanded state when the ! * {@code TreeModel} changes. * <p> * For more information on what expanded state means, see the * <a href=#jtree_description>JTree description</a> above. * * @return the instance of {@code TreeModelHandler}
*** 3773,3784 **** return new TreeModelHandler(); } /** * Removes any paths in the selection that are descendants of ! * <code>path</code>. If <code>includePath</code> is true and ! * <code>path</code> is selected, it will be removed from the selection. * * @param path a path * @param includePath is {@code true} and {@code path} is selected, * it will be removed from the selection. * @return true if a descendant was selected --- 3773,3784 ---- return new TreeModelHandler(); } /** * Removes any paths in the selection that are descendants of ! * {@code path}. If {@code includePath} is true and ! * {@code path} is selected, it will be removed from the selection. * * @param path a path * @param includePath is {@code true} and {@code path} is selected, * it will be removed from the selection. * @return true if a descendant was selected
*** 3795,3805 **** return false; } /** * Returns an array of paths in the selection that are descendants of ! * <code>path</code>. The returned array may contain <code>null</code>s. */ private TreePath[] getDescendantSelectedPaths(TreePath path, boolean includePath) { TreeSelectionModel sm = getSelectionModel(); TreePath[] selPaths = (sm != null) ? sm.getSelectionPaths() : --- 3795,3805 ---- return false; } /** * Returns an array of paths in the selection that are descendants of ! * {@code path}. The returned array may contain {@code null}s. */ private TreePath[] getDescendantSelectedPaths(TreePath path, boolean includePath) { TreeSelectionModel sm = getSelectionModel(); TreePath[] selPaths = (sm != null) ? sm.getSelectionPaths() :
*** 3824,3834 **** return null; } /** * Removes any paths from the selection model that are descendants of ! * the nodes identified by in <code>e</code>. */ void removeDescendantSelectedPaths(TreeModelEvent e) { TreePath pPath = SwingUtilities2.getTreePath(e, getModel()); Object[] oldChildren = e.getChildren(); TreeSelectionModel sm = getSelectionModel(); --- 3824,3834 ---- return null; } /** * Removes any paths from the selection model that are descendants of ! * the nodes identified by in {@code e}. */ void removeDescendantSelectedPaths(TreeModelEvent e) { TreePath pPath = SwingUtilities2.getTreePath(e, getModel()); Object[] oldChildren = e.getChildren(); TreeSelectionModel sm = getSelectionModel();
*** 3845,3855 **** } } /** ! * Listens to the model and updates the <code>expandedState</code> * accordingly when nodes are removed, or changed. */ protected class TreeModelHandler implements TreeModelListener { public void treeNodesChanged(TreeModelEvent e) { } --- 3845,3855 ---- } } /** ! * Listens to the model and updates the {@code expandedState} * accordingly when nodes are removed, or changed. */ protected class TreeModelHandler implements TreeModelListener { public void treeNodesChanged(TreeModelEvent e) { }
*** 3930,3971 **** } } /** ! * <code>DynamicUtilTreeNode</code> can wrap * vectors/hashtables/arrays/strings and * create the appropriate children tree nodes as necessary. It is * dynamic in that it will only create the children as necessary. * <p> * <strong>Warning:</strong> * Serialized objects of this class will not be compatible with * future Swing releases. The current serialization support is * appropriate for short term storage or RMI between applications running * the same version of Swing. As of 1.4, support for long term storage * of all JavaBeans&trade; ! * has been added to the <code>java.beans</code> package. * Please see {@link java.beans.XMLEncoder}. */ @SuppressWarnings("serial") public static class DynamicUtilTreeNode extends DefaultMutableTreeNode { /** ! * Does the this <code>JTree</code> have children? * This property is currently not implemented. */ protected boolean hasChildren; /** Value to create children with. */ protected Object childValue; /** Have the children been loaded yet? */ protected boolean loadedChildren; /** ! * Adds to parent all the children in <code>children</code>. ! * If <code>children</code> is an array or vector all of its ! * elements are added is children, otherwise if <code>children</code> * is a hashtable all the key/value pairs are added in the order ! * <code>Enumeration</code> returns them. * * @param parent the parent node * @param children the children */ public static void createChildren(DefaultMutableTreeNode parent, --- 3930,3971 ---- } } /** ! * {@code DynamicUtilTreeNode} can wrap * vectors/hashtables/arrays/strings and * create the appropriate children tree nodes as necessary. It is * dynamic in that it will only create the children as necessary. * <p> * <strong>Warning:</strong> * Serialized objects of this class will not be compatible with * future Swing releases. The current serialization support is * appropriate for short term storage or RMI between applications running * the same version of Swing. As of 1.4, support for long term storage * of all JavaBeans&trade; ! * has been added to the {@code java.beans} package. * Please see {@link java.beans.XMLEncoder}. */ @SuppressWarnings("serial") public static class DynamicUtilTreeNode extends DefaultMutableTreeNode { /** ! * Does the this {@code JTree} have children? * This property is currently not implemented. */ protected boolean hasChildren; /** Value to create children with. */ protected Object childValue; /** Have the children been loaded yet? */ protected boolean loadedChildren; /** ! * Adds to parent all the children in {@code children}. ! * If {@code children} is an array or vector all of its ! * elements are added is children, otherwise if {@code children} * is a hashtable all the key/value pairs are added in the order ! * {@code Enumeration} returns them. * * @param parent the parent node * @param children the children */ public static void createChildren(DefaultMutableTreeNode parent,
*** 4002,4022 **** /** * Creates a node with the specified object as its value and * with the specified children. For the node to allow children, * the children-object must be an array of objects, a ! * <code>Vector</code>, or a <code>Hashtable</code> -- even * if empty. Otherwise, the node is not * allowed to have children. * ! * @param value the <code>Object</code> that is the value for the * new node ! * @param children an array of <code>Object</code>s, a ! * <code>Vector</code>, or a <code>Hashtable</code> * used to create the child nodes; if any other * object is specified, or if the value is ! * <code>null</code>, * then the node is not allowed to have children */ public DynamicUtilTreeNode(Object value, Object children) { super(value); loadedChildren = false; --- 4002,4022 ---- /** * Creates a node with the specified object as its value and * with the specified children. For the node to allow children, * the children-object must be an array of objects, a ! * {@code Vector}, or a {@code Hashtable} -- even * if empty. Otherwise, the node is not * allowed to have children. * ! * @param value the {@code Object} that is the value for the * new node ! * @param children an array of {@code Object}s, a ! * {@code Vector}, or a {@code Hashtable} * used to create the child nodes; if any other * object is specified, or if the value is ! * {@code null}, * then the node is not allowed to have children */ public DynamicUtilTreeNode(Object value, Object children) { super(value); loadedChildren = false;
*** 4056,4071 **** loadChildren(); return super.getChildCount(); } /** ! * Loads the children based on <code>childValue</code>. ! * If <code>childValue</code> is a <code>Vector</code> * or array each element is added as a child, ! * if <code>childValue</code> is a <code>Hashtable</code> * each key/value pair is added in the order that ! * <code>Enumeration</code> returns the keys. */ protected void loadChildren() { loadedChildren = true; createChildren(this, childValue); } --- 4056,4071 ---- loadChildren(); return super.getChildCount(); } /** ! * Loads the children based on {@code childValue}. ! * If {@code childValue} is a {@code Vector} * or array each element is added as a child, ! * if {@code childValue} is a {@code Hashtable} * each key/value pair is added in the order that ! * {@code Enumeration} returns the keys. */ protected void loadChildren() { loadedChildren = true; createChildren(this, childValue); }
*** 4110,4127 **** } } /** ! * Returns a string representation of this <code>JTree</code>. * This method * is intended to be used only for debugging purposes, and the * content and format of the returned string may vary between * implementations. The returned string may be empty but may not ! * be <code>null</code>. * ! * @return a string representation of this <code>JTree</code>. */ protected String paramString() { String rootVisibleString = (rootVisible ? "true" : "false"); String showsRootHandlesString = (showsRootHandles ? --- 4110,4127 ---- } } /** ! * Returns a string representation of this {@code JTree}. * This method * is intended to be used only for debugging purposes, and the * content and format of the returned string may vary between * implementations. The returned string may be empty but may not ! * be {@code null}. * ! * @return a string representation of this {@code JTree}. */ protected String paramString() { String rootVisibleString = (rootVisible ? "true" : "false"); String showsRootHandlesString = (showsRootHandles ?
*** 4167,4186 **** return accessibleContext; } /** * This class implements accessibility support for the ! * <code>JTree</code> class. It provides an implementation of the * Java Accessibility API appropriate to tree user-interface elements. * <p> * <strong>Warning:</strong> * Serialized objects of this class will not be compatible with * future Swing releases. The current serialization support is * appropriate for short term storage or RMI between applications running * the same version of Swing. As of 1.4, support for long term storage * of all JavaBeans&trade; ! * has been added to the <code>java.beans</code> package. * Please see {@link java.beans.XMLEncoder}. */ @SuppressWarnings("serial") protected class AccessibleJTree extends AccessibleJComponent implements AccessibleSelection, TreeSelectionListener, --- 4167,4186 ---- return accessibleContext; } /** * This class implements accessibility support for the ! * {@code JTree} class. It provides an implementation of the * Java Accessibility API appropriate to tree user-interface elements. * <p> * <strong>Warning:</strong> * Serialized objects of this class will not be compatible with * future Swing releases. The current serialization support is * appropriate for short term storage or RMI between applications running * the same version of Swing. As of 1.4, support for long term storage * of all JavaBeans&trade; ! * has been added to the {@code java.beans} package. * Please see {@link java.beans.XMLEncoder}. */ @SuppressWarnings("serial") protected class AccessibleJTree extends AccessibleJComponent implements AccessibleSelection, TreeSelectionListener,
*** 4402,4418 **** public AccessibleRole getAccessibleRole() { return AccessibleRole.TREE; } /** ! * Returns the <code>Accessible</code> child, if one exists, ! * contained at the local coordinate <code>Point</code>. ! * Otherwise returns <code>null</code>. ! * ! * @param p point in local coordinates of this <code>Accessible</code> ! * @return the <code>Accessible</code>, if it exists, ! * at the specified location; else <code>null</code> */ public Accessible getAccessibleAt(Point p) { TreePath path = getClosestPathForLocation(p.x, p.y); if (path != null) { // JTree.this is NOT the parent; parent will get computed later --- 4402,4418 ---- public AccessibleRole getAccessibleRole() { return AccessibleRole.TREE; } /** ! * Returns the {@code Accessible} child, if one exists, ! * contained at the local coordinate {@code Point}. ! * Otherwise returns {@code null}. ! * ! * @param p point in local coordinates of this {@code Accessible} ! * @return the {@code Accessible}, if it exists, ! * at the specified location; else {@code null} */ public Accessible getAccessibleAt(Point p) { TreePath path = getClosestPathForLocation(p.x, p.y); if (path != null) { // JTree.this is NOT the parent; parent will get computed later
*** 4649,4659 **** } } /** * This class implements accessibility support for the ! * <code>JTree</code> child. It provides an implementation of the * Java Accessibility API appropriate to tree nodes. */ protected class AccessibleJTreeNode extends AccessibleContext implements Accessible, AccessibleComponent, AccessibleSelection, AccessibleAction { --- 4649,4659 ---- } } /** * This class implements accessibility support for the ! * {@code JTree} child. It provides an implementation of the * Java Accessibility API appropriate to tree nodes. */ protected class AccessibleJTreeNode extends AccessibleContext implements Accessible, AccessibleComponent, AccessibleSelection, AccessibleAction {
*** 5372,5389 **** } } } /** ! * Returns the <code>Accessible</code> child, if one exists, ! * contained at the local coordinate <code>Point</code>. ! * Otherwise returns <code>null</code>. * * @param p point in local coordinates of this ! * <code>Accessible</code> ! * @return the <code>Accessible</code>, if it exists, ! * at the specified location; else <code>null</code> */ public Accessible getAccessibleAt(Point p) { AccessibleContext ac = getCurrentAccessibleContext(); if (ac instanceof AccessibleComponent) { return ((AccessibleComponent) ac).getAccessibleAt(p); --- 5372,5389 ---- } } } /** ! * Returns the {@code Accessible} child, if one exists, ! * contained at the local coordinate {@code Point}. ! * Otherwise returns {@code null}. * * @param p point in local coordinates of this ! * {@code Accessible} ! * @return the {@code Accessible}, if it exists, ! * at the specified location; else {@code null} */ public Accessible getAccessibleAt(Point p) { AccessibleContext ac = getCurrentAccessibleContext(); if (ac instanceof AccessibleComponent) { return ((AccessibleComponent) ac).getAccessibleAt(p);
< prev index next >