javax.swing.tree

Class DefaultTreeCellEditor

  • All Implemented Interfaces:
    ActionListener, EventListener, CellEditor, TreeSelectionListener, TreeCellEditor

    public class DefaultTreeCellEditor
    extends Object
    implements ActionListener, TreeCellEditor, TreeSelectionListener
    A TreeCellEditor. You need to supply an instance of DefaultTreeCellRenderer so that the icons can be obtained. You can optionally supply a TreeCellEditor that will be layed out according to the icon in the DefaultTreeCellRenderer. If you do not supply a TreeCellEditor, a TextField will be used. Editing is started on a triple mouse click, or after a click, pause, click and a delay of 1200 miliseconds.

    Warning: 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 JavaBeansTM has been added to the java.beans package. Please see XMLEncoder.

    See Also:
    JTree
    • Field Detail

      • realEditor

        protected TreeCellEditor realEditor
        Editor handling the editing.
      • editingContainer

        protected Container editingContainer
        Editing container, will contain the editorComponent.
      • editingComponent

        protected transient Component editingComponent
        Component used in editing, obtained from the editingContainer.
      • canEdit

        protected boolean canEdit
        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 isCellEditable.
      • offset

        protected transient int offset
        Used in editing. Indicates x position to place editingComponent.
      • tree

        protected transient JTree tree
        JTree instance listening too.
      • lastPath

        protected transient TreePath lastPath
        Last path that was selected.
      • timer

        protected transient Timer timer
        Used before starting the editing session.
      • lastRow

        protected transient int lastRow
        Row that was last passed into getTreeCellEditorComponent.
      • borderSelectionColor

        protected Color borderSelectionColor
        True if the border selection color should be drawn.
      • editingIcon

        protected transient Icon editingIcon
        Icon to use when editing.
      • font

        protected Font font
        Font to paint with, null indicates font of renderer is to be used.
    • Constructor Detail

      • DefaultTreeCellEditor

        public DefaultTreeCellEditor(JTree tree,
                             DefaultTreeCellRenderer renderer)
        Constructs a DefaultTreeCellEditor object for a JTree using the specified renderer and a default editor. (Use this constructor for normal editing.)
        Parameters:
        tree - a JTree object
        renderer - a DefaultTreeCellRenderer object
      • DefaultTreeCellEditor

        public DefaultTreeCellEditor(JTree tree,
                             DefaultTreeCellRenderer renderer,
                             TreeCellEditor editor)
        Constructs a DefaultTreeCellEditor object for a JTree using the specified renderer and the specified editor. (Use this constructor for specialized editing.)
        Parameters:
        tree - a JTree object
        renderer - a DefaultTreeCellRenderer object
        editor - a TreeCellEditor object
    • Method Detail

      • setBorderSelectionColor

        public void setBorderSelectionColor(Color newColor)
        Sets the color to use for the border.
        Parameters:
        newColor - the new border color
      • getBorderSelectionColor

        public Color getBorderSelectionColor()
        Returns the color the border is drawn.
        Returns:
        the border selection color
      • setFont

        public void setFont(Font font)
        Sets the font to edit with. null indicates the renderers font should be used. This will NOT override any font you have set in the editor the receiver was instantied with. If null for an editor was passed in a default editor will be created that will pick up this font.
        Parameters:
        font - the editing Font
        See Also:
        getFont()
      • getTreeCellEditorComponent

        public Component getTreeCellEditorComponent(JTree tree,
                                           Object value,
                                           boolean isSelected,
                                           boolean expanded,
                                           boolean leaf,
                                           int row)
        Configures the editor. Passed onto the realEditor.
        Specified by:
        getTreeCellEditorComponent in interface TreeCellEditor
        Parameters:
        tree - the JTree that is asking the editor to edit; this parameter can be null
        value - the value of the cell to be edited
        isSelected - true if the cell is to be rendered with selection highlighting
        expanded - true if the node is expanded
        leaf - true if the node is a leaf node
        row - the row index of the node being edited
        Returns:
        the component for editing
      • getCellEditorValue

        public Object getCellEditorValue()
        Returns the value currently being edited.
        Specified by:
        getCellEditorValue in interface CellEditor
        Returns:
        the value currently being edited
      • stopCellEditing

        public boolean stopCellEditing()
        If the realEditor will allow editing to stop, the realEditor is removed and true is returned, otherwise false is returned.
        Specified by:
        stopCellEditing in interface CellEditor
        Returns:
        true if editing was stopped; false otherwise
      • cancelCellEditing

        public void cancelCellEditing()
        Messages cancelCellEditing to the realEditor and removes it from this instance.
        Specified by:
        cancelCellEditing in interface CellEditor
      • getCellEditorListeners

        public CellEditorListener[] getCellEditorListeners()
        Returns an array of all the CellEditorListeners added to this DefaultTreeCellEditor with addCellEditorListener().
        Returns:
        all of the CellEditorListeners added or an empty array if no listeners have been added
        Since:
        1.4
      • setTree

        protected void setTree(JTree newTree)
        Sets the tree currently editing for. This is needed to add a selection listener.
        Parameters:
        newTree - the new tree to be edited
      • shouldStartEditingTimer

        protected boolean shouldStartEditingTimer(EventObject event)
        Returns true if event is a MouseEvent and the click count is 1.
        Parameters:
        event - the event being studied
      • startEditingTimer

        protected void startEditingTimer()
        Starts the editing timer.
      • canEditImmediately

        protected boolean canEditImmediately(EventObject event)
        Returns true if event is null, or it is a MouseEvent with a click count > 2 and inHitRegion returns true.
        Parameters:
        event - the event being studied
      • inHitRegion

        protected boolean inHitRegion(int x,
                          int y)
        Returns true if the passed in location is a valid mouse location to start editing from. This is implemented to return false if 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.
        Parameters:
        x - the x-coordinate of the point
        y - the y-coordinate of the point
        Returns:
        true if the passed in location is a valid mouse location
      • determineOffset

        protected void determineOffset(JTree tree,
                           Object value,
                           boolean isSelected,
                           boolean expanded,
                           boolean leaf,
                           int row)
      • prepareForEditing

        protected void prepareForEditing()
        Invoked just before editing is to start. Will add the editingComponent to the editingContainer.
      • createContainer

        protected Container createContainer()
        Creates the container to manage placement of editingComponent.
      • createTreeCellEditor

        protected TreeCellEditor createTreeCellEditor()
        This is invoked if a TreeCellEditor is not supplied in the constructor. It returns a TextField editor.
        Returns:
        a new TextField editor

Deutsche Übersetzung

Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.

Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.

Vielen Dank im Voraus.

Dokument erstellt 11/06/2005, zuletzt geändert 04/03/2020
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/java-api-rf-javax/swing/tree/defaulttreecelleditor.html

Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.

Referenzen

  1. Zeigen Sie - html-Dokument Sprache des Dokuments:fr Manuel PHP : https://docs.oracle.com

Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor Diese Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.

Inhaltsverzeichnis Haut