< prev index next >
src/java.desktop/share/classes/javax/swing/tree/DefaultTreeCellEditor.java
Print this page
@@ -32,27 +32,27 @@
import java.awt.*;
import java.awt.event.*;
import java.util.EventObject;
/**
- * A <code>TreeCellEditor</code>. You need to supply an
- * instance of <code>DefaultTreeCellRenderer</code>
+ * A {@code TreeCellEditor}. You need to supply an
+ * instance of {@code DefaultTreeCellRenderer}
* so that the icons can be obtained. You can optionally supply
- * a <code>TreeCellEditor</code> that will be layed out according
- * to the icon in the <code>DefaultTreeCellRenderer</code>.
- * If you do not supply a <code>TreeCellEditor</code>,
- * a <code>TextField</code> will be used. Editing is started
+ * a {@code TreeCellEditor} that will be layed out according
+ * to the icon in the {@code DefaultTreeCellRenderer}.
+ * If you do not supply a {@code TreeCellEditor},
+ * a {@code TextField} will be used. Editing is started
* on a triple mouse click, or after a click, pause, click and
* a delay of 1200 milliseconds.
*<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™
- * has been added to the <code>java.beans</code> package.
+ * has been added to the {@code java.beans} package.
* Please see {@link java.beans.XMLEncoder}.
*
* @see javax.swing.JTree
*
* @author Scott Violet
@@ -63,82 +63,82 @@
protected TreeCellEditor realEditor;
/** Renderer, used to get border and offsets from. */
protected DefaultTreeCellRenderer renderer;
- /** Editing container, will contain the <code>editorComponent</code>. */
+ /** Editing container, will contain the {@code editorComponent}. */
protected Container editingContainer;
/**
* Component used in editing, obtained from the
- * <code>editingContainer</code>.
+ * {@code editingContainer}.
*/
protected transient Component editingComponent;
/**
* As of Java 2 platform v1.4 this field should no longer be used. If
* you wish to provide similar behavior you should directly override
- * <code>isCellEditable</code>.
+ * {@code isCellEditable}.
*/
protected boolean canEdit;
/**
* Used in editing. Indicates x position to place
- * <code>editingComponent</code>.
+ * {@code editingComponent}.
*/
protected transient int offset;
- /** <code>JTree</code> instance listening too. */
+ /** {@code JTree} instance listening too. */
protected transient JTree tree;
/** Last path that was selected. */
protected transient TreePath lastPath;
/** Used before starting the editing session. */
protected transient Timer timer;
/**
* Row that was last passed into
- * <code>getTreeCellEditorComponent</code>.
+ * {@code getTreeCellEditorComponent}.
*/
protected transient int lastRow;
/** True if the border selection color should be drawn. */
protected Color borderSelectionColor;
/** Icon to use when editing. */
protected transient Icon editingIcon;
/**
- * Font to paint with, <code>null</code> indicates
+ * Font to paint with, {@code null} indicates
* font of renderer is to be used.
*/
protected Font font;
/**
- * Constructs a <code>DefaultTreeCellEditor</code>
+ * Constructs a {@code DefaultTreeCellEditor}
* object for a JTree using the specified renderer and
* a default editor. (Use this constructor for normal editing.)
*
- * @param tree a <code>JTree</code> object
- * @param renderer a <code>DefaultTreeCellRenderer</code> object
+ * @param tree a {@code JTree} object
+ * @param renderer a {@code DefaultTreeCellRenderer} object
*/
public DefaultTreeCellEditor(JTree tree,
DefaultTreeCellRenderer renderer) {
this(tree, renderer, null);
}
/**
- * Constructs a <code>DefaultTreeCellEditor</code>
- * object for a <code>JTree</code> using the
+ * Constructs a {@code DefaultTreeCellEditor}
+ * object for a {@code JTree} using the
* specified renderer and the specified editor. (Use this constructor
* for specialized editing.)
*
- * @param tree a <code>JTree</code> object
- * @param renderer a <code>DefaultTreeCellRenderer</code> object
- * @param editor a <code>TreeCellEditor</code> object
+ * @param tree a {@code JTree} object
+ * @param renderer a {@code DefaultTreeCellRenderer} object
+ * @param editor a {@code TreeCellEditor} object
*/
public DefaultTreeCellEditor(JTree tree, DefaultTreeCellRenderer renderer,
TreeCellEditor editor) {
this.renderer = renderer;
realEditor = editor;
@@ -165,28 +165,28 @@
public Color getBorderSelectionColor() {
return borderSelectionColor;
}
/**
- * Sets the font to edit with. <code>null</code> indicates
+ * Sets the font to edit with. {@code null} indicates
* the renderers font should be used. This will NOT
* override any font you have set in the editor
- * the receiver was instantiated with. If <code>null</code>
+ * the receiver was instantiated with. If {@code null}
* for an editor was passed in a default editor will be
* created that will pick up this font.
*
- * @param font the editing <code>Font</code>
+ * @param font the editing {@code Font}
* @see #getFont
*/
public void setFont(Font font) {
this.font = font;
}
/**
* Gets the font used for editing.
*
- * @return the editing <code>Font</code>
+ * @return the editing {@code Font}
* @see #setFont
*/
public Font getFont() {
return font;
}
@@ -194,11 +194,11 @@
//
// TreeCellEditor
//
/**
- * Configures the editor. Passed onto the <code>realEditor</code>.
+ * Configures the editor. Passed onto the {@code realEditor}.
*/
public Component getTreeCellEditorComponent(JTree tree, Object value,
boolean isSelected,
boolean expanded,
boolean leaf, int row) {
@@ -240,12 +240,12 @@
public Object getCellEditorValue() {
return realEditor.getCellEditorValue();
}
/**
- * If the <code>realEditor</code> returns true to this
- * message, <code>prepareForEditing</code>
+ * If the {@code realEditor} returns true to this
+ * message, {@code prepareForEditing}
* is messaged and true is returned.
*/
public boolean isCellEditable(EventObject event) {
boolean retValue = false;
boolean editable = false;
@@ -285,19 +285,19 @@
prepareForEditing();
return retValue;
}
/**
- * Messages the <code>realEditor</code> for the return value.
+ * Messages the {@code realEditor} for the return value.
*/
public boolean shouldSelectCell(EventObject event) {
return realEditor.shouldSelectCell(event);
}
/**
- * If the <code>realEditor</code> will allow editing to stop,
- * the <code>realEditor</code> is removed and true is returned,
+ * If the {@code realEditor} will allow editing to stop,
+ * the {@code realEditor} is removed and true is returned,
* otherwise false is returned.
*/
public boolean stopCellEditing() {
if(realEditor.stopCellEditing()) {
cleanupAfterEditing();
@@ -305,39 +305,39 @@
}
return false;
}
/**
- * Messages <code>cancelCellEditing</code> to the
- * <code>realEditor</code> and removes it from this instance.
+ * Messages {@code cancelCellEditing} to the
+ * {@code realEditor} and removes it from this instance.
*/
public void cancelCellEditing() {
realEditor.cancelCellEditing();
cleanupAfterEditing();
}
/**
- * Adds the <code>CellEditorListener</code>.
+ * Adds the {@code CellEditorListener}.
* @param l the listener to be added
*/
public void addCellEditorListener(CellEditorListener l) {
realEditor.addCellEditorListener(l);
}
/**
- * Removes the previously added <code>CellEditorListener</code>.
+ * Removes the previously added {@code CellEditorListener}.
* @param l the listener to be removed
*/
public void removeCellEditorListener(CellEditorListener l) {
realEditor.removeCellEditorListener(l);
}
/**
- * Returns an array of all the <code>CellEditorListener</code>s added
+ * Returns an array of all the {@code CellEditorListener}s added
* to this DefaultTreeCellEditor with addCellEditorListener().
*
- * @return all of the <code>CellEditorListener</code>s added or an empty
+ * @return all of the {@code CellEditorListener}s added or an empty
* array if no listeners have been added
* @since 1.4
*/
public CellEditorListener[] getCellEditorListeners() {
return ((DefaultCellEditor)realEditor).getCellEditorListeners();
@@ -346,11 +346,11 @@
//
// TreeSelectionListener
//
/**
- * Resets <code>lastPath</code>.
+ * Resets {@code lastPath}.
*/
public void valueChanged(TreeSelectionEvent e) {
if(tree != null) {
if(tree.getSelectionCount() == 1)
lastPath = tree.getSelectionPath();
@@ -397,11 +397,11 @@
}
}
}
/**
- * Returns true if <code>event</code> is a <code>MouseEvent</code>
+ * Returns true if {@code event} is a {@code MouseEvent}
* and the click count is 1.
*
* @param event the event being studied
* @return whether {@code event} should starts the editing timer
*/
@@ -426,13 +426,13 @@
}
timer.start();
}
/**
- * Returns true if <code>event</code> is <code>null</code>,
- * or it is a <code>MouseEvent</code> with a click count > 2
- * and <code>inHitRegion</code> returns true.
+ * Returns true if {@code event} is {@code null},
+ * or it is a {@code MouseEvent} with a click count > 2
+ * and {@code inHitRegion} returns true.
*
* @param event the event being studied
* @return whether editing can be started for the given {@code event}
*/
protected boolean canEditImmediately(EventObject event) {
@@ -447,11 +447,11 @@
}
/**
* Returns true if the passed in location is a valid mouse location
* to start editing from. This is implemented to return false if
- * <code>x</code> is <= the width of the icon and icon gap displayed
+ * {@code x} is <= the width of the icon and icon gap displayed
* by the renderer. In other words this returns true if the user
* clicks over the text part displayed by the renderer, and false
* otherwise.
* @param x the x-coordinate of the point
* @param y the y-coordinate of the point
@@ -477,11 +477,11 @@
return true;
}
/**
* Determine the offset.
- * @param tree a <code>JTree</code> object
+ * @param tree a {@code JTree} object
* @param value a value
* @param isSelected selection status
* @param expanded expansion status
* @param leaf leaf status
* @param row current row
@@ -508,34 +508,34 @@
}
}
/**
* Invoked just before editing is to start. Will add the
- * <code>editingComponent</code> to the
- * <code>editingContainer</code>.
+ * {@code editingComponent} to the
+ * {@code editingContainer}.
*/
protected void prepareForEditing() {
if (editingComponent != null) {
editingContainer.add(editingComponent);
}
}
/**
* Creates the container to manage placement of
- * <code>editingComponent</code>.
+ * {@code editingComponent}.
*
* @return new Container object
*/
protected Container createContainer() {
return new EditorContainer();
}
/**
- * This is invoked if a <code>TreeCellEditor</code>
+ * This is invoked if a {@code TreeCellEditor}
* is not supplied in the constructor.
- * It returns a <code>TextField</code> editor.
- * @return a new <code>TextField</code> editor
+ * It returns a {@code TextField} editor.
+ * @return a new {@code TextField} editor
*/
protected TreeCellEditor createTreeCellEditor() {
Border aBorder = UIManager.getBorder("Tree.editorBorder");
@SuppressWarnings("serial") // Safe: outer class is non-serializable
DefaultCellEditor editor = new DefaultCellEditor
@@ -551,36 +551,36 @@
return editor;
}
/**
* Cleans up any state after editing has completed. Removes the
- * <code>editingComponent</code> the <code>editingContainer</code>.
+ * {@code editingComponent} the {@code editingContainer}.
*/
private void cleanupAfterEditing() {
if (editingComponent != null) {
editingContainer.remove(editingComponent);
}
editingComponent = null;
}
/**
- * <code>TextField</code> used when no editor is supplied.
+ * {@code TextField} used when no editor is supplied.
* This textfield locks into the border it is constructed with.
* It also prefers its parents font over its font. And if the
- * renderer is not <code>null</code> and no font
+ * renderer is not {@code null} and no font
* has been specified the preferred height is that of the renderer.
*/
@SuppressWarnings("serial") // Safe: outer class is non-serializable
public class DefaultTextField extends JTextField {
/** Border to use. */
protected Border border;
/**
* Constructs a
- * <code>DefaultTreeCellEditor.DefaultTextField</code> object.
+ * {@code DefaultTreeCellEditor.DefaultTextField} object.
*
- * @param border a <code>Border</code> object
+ * @param border a {@code Border} object
* @since 1.4
*/
public DefaultTextField(Border border) {
setBorder(border);
}
@@ -602,11 +602,11 @@
super.setBorder(border);
this.border = border;
}
/**
- * Overrides <code>JComponent.getBorder</code> to
+ * Overrides {@code JComponent.getBorder} to
* returns the current border.
*/
public Border getBorder() {
return border;
}
@@ -625,14 +625,14 @@
}
return font;
}
/**
- * Overrides <code>JTextField.getPreferredSize</code> to
+ * Overrides {@code JTextField.getPreferredSize} to
* return the preferred size based on current font, if set,
* or else use renderer's font.
- * @return a <code>Dimension</code> object containing
+ * @return a {@code Dimension} object containing
* the preferred size
*/
public Dimension getPreferredSize() {
Dimension size = super.getPreferredSize();
@@ -647,16 +647,16 @@
}
}
/**
- * Container responsible for placing the <code>editingComponent</code>.
+ * Container responsible for placing the {@code editingComponent}.
*/
@SuppressWarnings("serial") // Safe: outer class is non-serializable
public class EditorContainer extends Container {
/**
- * Constructs an <code>EditorContainer</code> object.
+ * Constructs an {@code EditorContainer} object.
*/
public EditorContainer() {
setLayout(null);
}
@@ -668,11 +668,11 @@
public void EditorContainer() {
setLayout(null);
}
/**
- * Overrides <code>Container.paint</code> to paint the node's
+ * Overrides {@code Container.paint} to paint the node's
* icon and use the selection color for the background.
*/
public void paint(Graphics g) {
int width = getWidth();
int height = getHeight();
@@ -698,13 +698,13 @@
}
super.paint(g);
}
/**
- * Lays out this <code>Container</code>. If editing,
+ * Lays out this {@code Container}. If editing,
* the editor will be placed at
- * <code>offset</code> in the x direction and 0 for y.
+ * {@code offset} in the x direction and 0 for y.
*/
public void doLayout() {
if(editingComponent != null) {
int width = getWidth();
int height = getHeight();
@@ -734,17 +734,17 @@
totalY;
return getHeight() / 2 - (totalY + (totalHeight / 2));
}
/**
- * Returns the preferred size for the <code>Container</code>.
+ * Returns the preferred size for the {@code Container}.
* This will be at least preferred size of the editor plus
- * <code>offset</code>.
- * @return a <code>Dimension</code> containing the preferred
- * size for the <code>Container</code>; if
- * <code>editingComponent</code> is <code>null</code> the
- * <code>Dimension</code> returned is 0, 0
+ * {@code offset}.
+ * @return a {@code Dimension} containing the preferred
+ * size for the {@code Container}; if
+ * {@code editingComponent} is {@code null} the
+ * {@code Dimension} returned is 0, 0
*/
public Dimension getPreferredSize() {
if(editingComponent != null) {
Dimension pSize = editingComponent.getPreferredSize();
< prev index next >