Class JTreeTable.TreeTableCellEditor

  • All Implemented Interfaces:
    java.io.Serializable, javax.swing.CellEditor, javax.swing.table.TableCellEditor, javax.swing.tree.TreeCellEditor
    Enclosing class:
    JTreeTable

    public class JTreeTable.TreeTableCellEditor
    extends javax.swing.DefaultCellEditor
    An editor that can be used to edit the tree column. This extends DefaultCellEditor and uses a JTextField (actually, TreeTableTextField) to perform the actual editing. reshape method in the JTextField component to nudge the textfield to the location tree would place it. Since JTreeTable will paint the tree behind the editor everything should just work. So, that is what we are doing here. Determining of the icon position will only work if the TreeCellRenderer is an instance of DefaultTreeCellRenderer. If you need custom TreeCellRenderers, that don't descend from DefaultTreeCellRenderer, and you want to support editing in JTreeTable, you will have to do something similiar.
    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class javax.swing.DefaultCellEditor

        javax.swing.DefaultCellEditor.EditorDelegate
    • Field Summary

      • Fields inherited from class javax.swing.DefaultCellEditor

        clickCountToStart, delegate, editorComponent
      • Fields inherited from class javax.swing.AbstractCellEditor

        changeEvent, listenerList
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.awt.Component getTableCellEditorComponent​(javax.swing.JTable table, java.lang.Object value, boolean isSelected, int r, int c)
      Overridden to determine an offset that tree would place the editor at.
      boolean isCellEditable​(java.util.EventObject e)
      This is overridden to forward the event to the tree.
      • Methods inherited from class javax.swing.DefaultCellEditor

        cancelCellEditing, getCellEditorValue, getClickCountToStart, getComponent, getTreeCellEditorComponent, setClickCountToStart, shouldSelectCell, stopCellEditing
      • Methods inherited from class javax.swing.AbstractCellEditor

        addCellEditorListener, fireEditingCanceled, fireEditingStopped, getCellEditorListeners, removeCellEditorListener
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface javax.swing.CellEditor

        addCellEditorListener, removeCellEditorListener
    • Constructor Detail

      • TreeTableCellEditor

        public TreeTableCellEditor()
    • Method Detail

      • getTableCellEditorComponent

        public java.awt.Component getTableCellEditorComponent​(javax.swing.JTable table,
                                                              java.lang.Object value,
                                                              boolean isSelected,
                                                              int r,
                                                              int c)
        Overridden to determine an offset that tree would place the editor at. The offset is determined from the getRowBounds JTree method, and additionally from the icon DefaultTreeCellRenderer will use.
        Specified by:
        getTableCellEditorComponent in interface javax.swing.table.TableCellEditor
        Overrides:
        getTableCellEditorComponent in class javax.swing.DefaultCellEditor
      • isCellEditable

        public boolean isCellEditable​(java.util.EventObject e)
        This is overridden to forward the event to the tree. This will return true if the click count >= 3, or the event is null.
        Specified by:
        isCellEditable in interface javax.swing.CellEditor
        Overrides:
        isCellEditable in class javax.swing.DefaultCellEditor