2362N/A * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * A <code>TreeCellEditor</code>. You need to supply an 0N/A * instance of <code>DefaultTreeCellRenderer</code> 0N/A * so that the icons can be obtained. You can optionally supply 0N/A * a <code>TreeCellEditor</code> that will be layed out according 0N/A * to the icon in the <code>DefaultTreeCellRenderer</code>. 0N/A * If you do not supply a <code>TreeCellEditor</code>, 0N/A * a <code>TextField</code> will be used. Editing is started 0N/A * on a triple mouse click, or after a click, pause, click and 0N/A * a delay of 1200 miliseconds. 0N/A * <strong>Warning:</strong> 0N/A * Serialized objects of this class will not be compatible with 0N/A * future Swing releases. The current serialization support is 0N/A * appropriate for short term storage or RMI between applications running 0N/A * the same version of Swing. As of 1.4, support for long term storage 0N/A * of all JavaBeans<sup><font size="-2">TM</font></sup> 0N/A * has been added to the <code>java.beans</code> package. 0N/A * @see javax.swing.JTree 0N/A * @author Scott Violet 0N/A /** Editor handling the editing. */ 0N/A /** Renderer, used to get border and offsets from. */ 0N/A /** Editing container, will contain the <code>editorComponent</code>. */ 0N/A * Component used in editing, obtained from the 0N/A * <code>editingContainer</code>. 0N/A * As of Java 2 platform v1.4 this field should no longer be used. If 0N/A * you wish to provide similar behavior you should directly override 0N/A * <code>isCellEditable</code>. 0N/A * Used in editing. Indicates x position to place 0N/A * <code>editingComponent</code>. 0N/A /** <code>JTree</code> instance listening too. */ 0N/A /** Last path that was selected. */ 0N/A /** Used before starting the editing session. */ 0N/A * Row that was last passed into 0N/A * <code>getTreeCellEditorComponent</code>. 0N/A /** True if the border selection color should be drawn. */ 0N/A /** Icon to use when editing. */ 0N/A * Font to paint with, <code>null</code> indicates 0N/A * font of renderer is to be used. 0N/A * Constructs a <code>DefaultTreeCellEditor</code> 0N/A * object for a JTree using the specified renderer and 0N/A * a default editor. (Use this constructor for normal editing.) 0N/A * @param tree a <code>JTree</code> object 0N/A * @param renderer a <code>DefaultTreeCellRenderer</code> object 0N/A * Constructs a <code>DefaultTreeCellEditor</code> 0N/A * object for a <code>JTree</code> using the 0N/A * specified renderer and the specified editor. (Use this constructor 0N/A * for specialized editing.) 0N/A * @param tree a <code>JTree</code> object 0N/A * @param renderer a <code>DefaultTreeCellRenderer</code> object 0N/A * @param editor a <code>TreeCellEditor</code> object 0N/A (
"Tree.editorBorderSelectionColor"));
0N/A * Sets the color to use for the border. 0N/A * @param newColor the new border color 0N/A * Returns the color the border is drawn. 0N/A * @return the border selection color 0N/A * Sets the font to edit with. <code>null</code> indicates 0N/A * the renderers font should be used. This will NOT 0N/A * override any font you have set in the editor 0N/A * the receiver was instantied with. If <code>null</code> 0N/A * for an editor was passed in a default editor will be 0N/A * created that will pick up this font. 0N/A * @param font the editing <code>Font</code> 0N/A * Gets the font used for editing. 0N/A * @return the editing <code>Font</code> 0N/A * Configures the editor. Passed onto the <code>realEditor</code>. 0N/A // this is kept for backwards compatability but isn't really needed 0N/A // with the current BasicTreeUI implementation. 0N/A * Returns the value currently being edited. 0N/A * @return the value currently being edited 0N/A * If the <code>realEditor</code> returns true to this 0N/A * message, <code>prepareForEditing</code> 0N/A * is messaged and true is returned. 0N/A * Messages the <code>realEditor</code> for the return value. 0N/A * If the <code>realEditor</code> will allow editing to stop, 0N/A * the <code>realEditor</code> is removed and true is returned, 0N/A * otherwise false is returned. 0N/A * Messages <code>cancelCellEditing</code> to the 0N/A * <code>realEditor</code> and removes it from this instance. 0N/A * Adds the <code>CellEditorListener</code>. 0N/A * @param l the listener to be added 0N/A * Removes the previously added <code>CellEditorListener</code>. 0N/A * @param l the listener to be removed 0N/A * Returns an array of all the <code>CellEditorListener</code>s added 0N/A * to this DefaultTreeCellEditor with addCellEditorListener(). 0N/A * @return all of the <code>CellEditorListener</code>s added or an empty 0N/A * array if no listeners have been added 0N/A // TreeSelectionListener 0N/A * Resets <code>lastPath</code>. 0N/A // ActionListener (for Timer). 0N/A * Messaged when the timer fires, this will start the editing 0N/A * Sets the tree currently editing for. This is needed to add 0N/A * a selection listener. 0N/A * @param newTree the new tree to be edited 0N/A * Returns true if <code>event</code> is a <code>MouseEvent</code> 0N/A * and the click count is 1. 0N/A * @param event the event being studied 0N/A * Starts the editing timer. 0N/A * Returns true if <code>event</code> is <code>null</code>, 0N/A * or it is a <code>MouseEvent</code> with a click count > 2 0N/A * and <code>inHitRegion</code> returns true. 0N/A * @param event the event being studied 0N/A * Returns true if the passed in location is a valid mouse location 0N/A * to start editing from. This is implemented to return false if 0N/A * <code>x</code> is <= the width of the icon and icon gap displayed 0N/A * by the renderer. In other words this returns true if the user 0N/A * clicks over the text part displayed by the renderer, and false 0N/A * @param x the x-coordinate of the point 0N/A * @param y the y-coordinate of the point 0N/A * @return true if the passed in location is a valid mouse location 0N/A * Invoked just before editing is to start. Will add the 0N/A * <code>editingComponent</code> to the 0N/A * <code>editingContainer</code>. 0N/A * Creates the container to manage placement of 0N/A * <code>editingComponent</code>. 0N/A * This is invoked if a <code>TreeCellEditor</code> 0N/A * is not supplied in the constructor. 0N/A * It returns a <code>TextField</code> editor. 0N/A * @return a new <code>TextField</code> editor 0N/A // One click to edit. 0N/A * Cleans up any state after editing has completed. Removes the 0N/A * <code>editingComponent</code> the <code>editingContainer</code>. 0N/A // Serialization support. 0N/A // Save the realEditor, if its Serializable. 0N/A * <code>TextField</code> used when no editor is supplied. 0N/A * This textfield locks into the border it is constructed with. 0N/A * It also prefers its parents font over its font. And if the 0N/A * renderer is not <code>null</code> and no font 0N/A * has been specified the preferred height is that of the renderer. 0N/A /** Border to use. */ 0N/A * <code>DefaultTreeCellEditor.DefaultTextField</code> object. 0N/A * @param border a <code>Border</code> object 0N/A * Sets the border of this component.<p> 0N/A * This is a bound property. 0N/A * @param border the border to be rendered for this component 0N/A * @see CompoundBorder 0N/A * attribute: visualUpdate true 0N/A * description: The component's border. 0N/A * Overrides <code>JComponent.getBorder</code> to 0N/A * returns the current border. 0N/A // implements java.awt.MenuContainer 0N/A // Prefer the parent containers font if our font is a 0N/A * Overrides <code>JTextField.getPreferredSize</code> to 0N/A * return the preferred size based on current font, if set, 0N/A * or else use renderer's font. 0N/A * @return a <code>Dimension</code> object containing 0N/A * the preferred size 0N/A // If not font has been set, prefer the renderers height. 0N/A * Container responsible for placing the <code>editingComponent</code>. 0N/A * Constructs an <code>EditorContainer</code> object. 0N/A // This should not be used. It will be removed when new API is 0N/A * Overrides <code>Container.paint</code> to paint the node's 0N/A * icon and use the selection color for the background. 0N/A // Border selection color 0N/A * Lays out this <code>Container</code>. If editing, 0N/A * the editor will be placed at 0N/A * <code>offset</code> in the x direction and 0 for y. 0N/A * Calculate the y location for the icon. 0N/A // To make sure the icon position matches that of the 0N/A // renderer, use the same algorithm as JLabel 0N/A // (SwingUtilities.layoutCompoundLabel). 0N/A * Returns the preferred size for the <code>Container</code>. 0N/A * This will be at least preferred size of the editor plus 0N/A * <code>offset</code>. 0N/A * @return a <code>Dimension</code> containing the preferred 0N/A * size for the <code>Container</code>; if 0N/A * <code>editingComponent</code> is <code>null</code> the 0N/A * <code>Dimension</code> returned is 0, 0 0N/A // Make sure width is at least 100.