jdk/src/share/classes/javax/swing/tree/DefaultTreeCellEditor.java

Print this page




   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package javax.swing.tree;
  27 
  28 import javax.swing.*;
  29 import javax.swing.border.*;
  30 import javax.swing.event.*;
  31 import javax.swing.plaf.FontUIResource;
  32 import java.awt.*;
  33 import java.awt.event.*;

  34 import java.util.EventObject;
  35 
  36 /**
  37  * A <code>TreeCellEditor</code>. You need to supply an
  38  * instance of <code>DefaultTreeCellRenderer</code>
  39  * so that the icons can be obtained. You can optionally supply
  40  * a <code>TreeCellEditor</code> that will be layed out according
  41  * to the icon in the <code>DefaultTreeCellRenderer</code>.
  42  * If you do not supply a <code>TreeCellEditor</code>,
  43  * a <code>TextField</code> will be used. Editing is started
  44  * on a triple mouse click, or after a click, pause, click and
  45  * a delay of 1200 milliseconds.
  46  *<p>
  47  * <strong>Warning:</strong>
  48  * Serialized objects of this class will not be compatible with
  49  * future Swing releases. The current serialization support is
  50  * appropriate for short term storage or RMI between applications running
  51  * the same version of Swing.  As of 1.4, support for long term storage
  52  * of all JavaBeans&trade;
  53  * has been added to the <code>java.beans</code> package.


 566         protected Border         border;
 567 
 568         /**
 569          * Constructs a
 570          * <code>DefaultTreeCellEditor.DefaultTextField</code> object.
 571          *
 572          * @param border  a <code>Border</code> object
 573          * @since 1.4
 574          */
 575         public DefaultTextField(Border border) {
 576             setBorder(border);
 577         }
 578 
 579         /**
 580          * Sets the border of this component.<p>
 581          * This is a bound property.
 582          *
 583          * @param border the border to be rendered for this component
 584          * @see Border
 585          * @see CompoundBorder
 586          * @beaninfo
 587          *        bound: true
 588          *    preferred: true
 589          *    attribute: visualUpdate true
 590          *  description: The component's border.
 591          */


 592         public void setBorder(Border border) {
 593             super.setBorder(border);
 594             this.border = border;
 595         }
 596 
 597         /**
 598          * Overrides <code>JComponent.getBorder</code> to
 599          * returns the current border.
 600          */
 601         public Border getBorder() {
 602             return border;
 603         }
 604 
 605         // implements java.awt.MenuContainer
 606         public Font getFont() {
 607             Font     font = super.getFont();
 608 
 609             // Prefer the parent containers font if our font is a
 610             // FontUIResource
 611             if(font instanceof FontUIResource) {




   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */

  25 package javax.swing.tree;
  26 
  27 import javax.swing.*;
  28 import javax.swing.border.*;
  29 import javax.swing.event.*;
  30 import javax.swing.plaf.FontUIResource;
  31 import java.awt.*;
  32 import java.awt.event.*;
  33 import java.beans.BeanProperty;
  34 import java.util.EventObject;
  35 
  36 /**
  37  * A <code>TreeCellEditor</code>. You need to supply an
  38  * instance of <code>DefaultTreeCellRenderer</code>
  39  * so that the icons can be obtained. You can optionally supply
  40  * a <code>TreeCellEditor</code> that will be layed out according
  41  * to the icon in the <code>DefaultTreeCellRenderer</code>.
  42  * If you do not supply a <code>TreeCellEditor</code>,
  43  * a <code>TextField</code> will be used. Editing is started
  44  * on a triple mouse click, or after a click, pause, click and
  45  * a delay of 1200 milliseconds.
  46  *<p>
  47  * <strong>Warning:</strong>
  48  * Serialized objects of this class will not be compatible with
  49  * future Swing releases. The current serialization support is
  50  * appropriate for short term storage or RMI between applications running
  51  * the same version of Swing.  As of 1.4, support for long term storage
  52  * of all JavaBeans&trade;
  53  * has been added to the <code>java.beans</code> package.


 566         protected Border         border;
 567 
 568         /**
 569          * Constructs a
 570          * <code>DefaultTreeCellEditor.DefaultTextField</code> object.
 571          *
 572          * @param border  a <code>Border</code> object
 573          * @since 1.4
 574          */
 575         public DefaultTextField(Border border) {
 576             setBorder(border);
 577         }
 578 
 579         /**
 580          * Sets the border of this component.<p>
 581          * This is a bound property.
 582          *
 583          * @param border the border to be rendered for this component
 584          * @see Border
 585          * @see CompoundBorder





 586          */
 587         @BeanProperty(preferred = true, visualUpdate = true, description
 588                 = "The component's border.")
 589         public void setBorder(Border border) {
 590             super.setBorder(border);
 591             this.border = border;
 592         }
 593 
 594         /**
 595          * Overrides <code>JComponent.getBorder</code> to
 596          * returns the current border.
 597          */
 598         public Border getBorder() {
 599             return border;
 600         }
 601 
 602         // implements java.awt.MenuContainer
 603         public Font getFont() {
 604             Font     font = super.getFont();
 605 
 606             // Prefer the parent containers font if our font is a
 607             // FontUIResource
 608             if(font instanceof FontUIResource) {