proyecto.arbol
Class ArbolFicheros.EditorListener
java.lang.Object
proyecto.arbol.ArbolFicheros.EditorListener
- All Implemented Interfaces:
- CellEditor, TreeCellEditor
- Enclosing class:
- ArbolFicheros
class ArbolFicheros.EditorListener
- extends Object
- implements TreeCellEditor
The listener interface for receiving editor events. The class that is
interested in processing a editor event implements this interface, and
the object created with that class is registered with a component using
the component's addEditorListener method. When
the editor event occurs, that object's appropriate
method is invoked.
- Author:
- Parras
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
textEditor
ArbolFicheros.TextFielEditor textEditor
- The text editor.
iDefaultNodo
DefaultMutableTreeNode iDefaultNodo
- The i default nodo.
valorAnterior
String valorAnterior
- The valor anterior.
ArbolFicheros.EditorListener
public ArbolFicheros.EditorListener()
- Constructor editor listener.
Creado : Parras, 18-abr-2009
getTreeCellEditorComponent
public Component getTreeCellEditorComponent(JTree tree,
Object value,
boolean isSelected,
boolean expanded,
boolean leaf,
int row)
- Devuelve el Component que se usará para editar el dato.
- Specified by:
getTreeCellEditorComponent
in interface TreeCellEditor
- Parameters:
tree
- JTree en el que está el dato que se va a editarvalue
- El dato a editar. Este valor debe meterse en el Component
que se usa para editar, de forma que sea el que se
muestre.isSelected
- Si el dato está seleccionado en el JTreeexpanded
- Si el nodo del dato está expandidoleaf
- Si el nodo del dato es hoja (no tiene hijos)row
- Fila del JTree en el que está el dato.
- Returns:
- El Component que hace de editor, mostrando value.
addCellEditorListener
public void addCellEditorListener(CellEditorListener l)
- Specified by:
addCellEditorListener
in interface CellEditor
getCellEditorValue
public Object getCellEditorValue()
- Debemos devolver el dato que ha recogido el editor.
- Specified by:
getCellEditorValue
in interface CellEditor
- Returns:
- El dato.
removeCellEditorListener
public void removeCellEditorListener(CellEditorListener l)
- Specified by:
removeCellEditorListener
in interface CellEditor
isCellEditable
public boolean isCellEditable(EventObject anEvent)
- Nos pasan el evento que ha sucedido sobre el nodo y debemos decidir
si es un evento para empezar a editar o no. En este ejemplo se
comprobará si es un triple click de ratón. El doble click ya lo tiene
reservado el JTree para expandir/contraer nodos.
- Specified by:
isCellEditable
in interface CellEditor
- Parameters:
anEvent
- Evento.
- Returns:
- true si se debe empezar a editar el nodo.
shouldSelectCell
public boolean shouldSelectCell(EventObject event)
- Para decidir si cuando se edita una celda, debe a su vez
seleccionarse. Habitualmente se devuelve true, ya que al editar se
suele querer que se seleccione. Se pude devolver false si se quiere
editar una celda sin que se deseleccionen otras posibles celdas del
JTree que estuvieran seleccionadas y sin que se seleccione la celda
que estamos editando.
- Specified by:
shouldSelectCell
in interface CellEditor
- Parameters:
event
- Evento que ha ocurrido sobre la celda.
- Returns:
- true si queremos que se seleccione.
stopCellEditing
public boolean stopCellEditing()
- Nos avisan que debemos detener la edición y aceptar el valor que haya
en el editor. Debemos devolver true si el valor del editor es valido
y lo aceptamos. false en caso de que ese valor no sea correcto y no
debamos aceptar la edicion.
- Specified by:
stopCellEditing
in interface CellEditor
- Returns:
- true
cancelCellEditing
public void cancelCellEditing()
- El JTree nos avisa de que se ha cancelado la edición, por ejemplo, el
usuario ha pinchado con el ratón en otro nodo sin terminar de editar
el nuestro.
- Specified by:
cancelCellEditing
in interface CellEditor