com.zfqjava.swing.cell
Class AbstractCellEditor

java.lang.Object
  |
  +--com.zfqjava.swing.cell.AbstractCellEditor
All Implemented Interfaces:
javax.swing.CellEditor, javax.swing.table.TableCellEditor, javax.swing.tree.TreeCellEditor
Direct Known Subclasses:
BooleanCellEditor, DateCellEditor, NumberCellEditor, ObjectCellEditor, StringCellEditor

public abstract class AbstractCellEditor
extends java.lang.Object
implements javax.swing.CellEditor, javax.swing.table.TableCellEditor, javax.swing.tree.TreeCellEditor

AbstractCellEditor provides a abstract cell editor, can be used as JTable, JTree cell editor.


Field Summary
protected  javax.swing.event.ChangeEvent changeEvent
           
protected  javax.swing.event.EventListenerList listenerList
           
protected  boolean useSelectionColor
          True use the selection color when the cell is selected.
 
Constructor Summary
AbstractCellEditor()
           
 
Method Summary
 void addCellEditorListener(javax.swing.event.CellEditorListener l)
          Adds a CellEditorListener to the listener list.
 void cancelCellEditing()
          Calls fireEditingCanceled.
protected abstract  void commitEdit()
          Commits the editing.
protected  void fireEditingCanceled()
          Notifies all listeners that have registered interest for notification on this event type.
protected  void fireEditingStopped()
          Notifies all listeners that have registered interest for notification on this event type.
 javax.swing.event.CellEditorListener[] getCellEditorListeners()
          Returns an array of all the CellEditorListeners added to this AbstractCellEditor with addCellEditorListener().
 java.lang.Object getCellEditorValue()
          Returns the value contained in the editor.
 CellProvider getCellProvider()
          Returns the cell provider to add extra info for current editor.
abstract  java.awt.Component getComponent()
          Returns the component for this editor.
 java.awt.Component getListCellEditorComponent(javax.swing.JList list, java.lang.Object value, int index, boolean isSelected)
          Sets an initial value for the editor.
 java.awt.Component getTableCellEditorComponent(javax.swing.JTable table, java.lang.Object value, boolean isSelected, int row, int column)
          Sets an initial value for the editor.
 java.awt.Component getTreeCellEditorComponent(javax.swing.JTree tree, java.lang.Object value, boolean isSelected, boolean expanded, boolean leaf, int row)
          Sets an initial value for the editor.
protected abstract  java.lang.Object getValue()
          Returns the value for current editor
 boolean isCellEditable(java.util.EventObject e)
          Returns true.
 void removeCellEditorListener(javax.swing.event.CellEditorListener l)
          Removes a CellEditorListener from the listener list.
 void setCellProvider(CellProvider provider)
          Sets the cell provider to add extra info for current editor.
protected abstract  void setValue(java.lang.Object value)
          Sets the value for current editor.
 boolean shouldSelectCell(java.util.EventObject anEvent)
          Returns true.
 boolean stopCellEditing()
          Calls fireEditingStopped and returns true.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

useSelectionColor

protected boolean useSelectionColor
True use the selection color when the cell is selected. The default is false.

listenerList

protected javax.swing.event.EventListenerList listenerList

changeEvent

protected transient javax.swing.event.ChangeEvent changeEvent
Constructor Detail

AbstractCellEditor

public AbstractCellEditor()
Method Detail

getListCellEditorComponent

public java.awt.Component getListCellEditorComponent(javax.swing.JList list,
                                                     java.lang.Object value,
                                                     int index,
                                                     boolean isSelected)
Sets an initial value for the editor. This will cause the editor to stopEditing and lose any partially edited value if the editor is editing when this method is called.

Returns the component that should be added to the client's Component hierarchy. Once installed in the client's hierarchy this component will then be able to draw and receive user input.

Parameters:
list - the JList that is asking the editor to edit; can be null The JList we're painting.
value - The value returned by list.getModel().getElementAt(index).
index - The cells index.
isSelected - True if the specified cell was selected.
Returns:
the component for editing

getTableCellEditorComponent

public java.awt.Component getTableCellEditorComponent(javax.swing.JTable table,
                                                      java.lang.Object value,
                                                      boolean isSelected,
                                                      int row,
                                                      int column)
Sets an initial value for the editor. This will cause the editor to stopEditing and lose any partially edited value if the editor is editing when this method is called.

Returns the component that should be added to the client's Component hierarchy. Once installed in the client's hierarchy this component will then be able to draw and receive user input.

Specified by:
getTableCellEditorComponent in interface javax.swing.table.TableCellEditor
Parameters:
table - the JTable that is asking the editor to edit; can be null
value - the value of the cell to be edited; it is up to the specific editor to interpret and draw the value. For example, if value is the string "true", it could be rendered as a string or it could be rendered as a check box that is checked. null is a valid value
isSelected - true if the cell is to be rendered with highlighting
row - the row of the cell being edited
column - the column of the cell being edited
Returns:
the component for editing

getTreeCellEditorComponent

public java.awt.Component getTreeCellEditorComponent(javax.swing.JTree tree,
                                                     java.lang.Object value,
                                                     boolean isSelected,
                                                     boolean expanded,
                                                     boolean leaf,
                                                     int row)
Sets an initial value for the editor. This will cause the editor to stopEditing and lose any partially edited value if the editor is editing when this method is called.

Returns the component that should be added to the client's Component hierarchy. Once installed in the client's hierarchy this component will then be able to draw and receive user input.

Specified by:
getTreeCellEditorComponent in interface javax.swing.tree.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 is the cell is to be renderer 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

setCellProvider

public void setCellProvider(CellProvider provider)
Sets the cell provider to add extra info for current editor.
Parameters:
provider - the cell provider
See Also:
getCellProvider()

getCellProvider

public CellProvider getCellProvider()
Returns the cell provider to add extra info for current editor.
Returns:
the cell provider to add extra info for current editor
See Also:
setCellProvider(com.zfqjava.swing.cell.CellProvider)

getComponent

public abstract java.awt.Component getComponent()
Returns the component for this editor.
Returns:
the component for this editor

setValue

protected abstract void setValue(java.lang.Object value)
Sets the value for current editor.
Parameters:
value - the value to editor

getValue

protected abstract java.lang.Object getValue()
Returns the value for current editor
Returns:
the value for current editor

commitEdit

protected abstract void commitEdit()
                            throws java.text.ParseException
Commits the editing. This invoke by stopCellEditing(), if cannot commit current editing, should throws exception.
Throws:
java.text.ParseException - if cannot commit the editing

getCellEditorValue

public java.lang.Object getCellEditorValue()
Returns the value contained in the editor.
Specified by:
getCellEditorValue in interface javax.swing.CellEditor
Returns:
the value contained in the editor

isCellEditable

public boolean isCellEditable(java.util.EventObject e)
Returns true.
Specified by:
isCellEditable in interface javax.swing.CellEditor
Parameters:
e - an event object
Returns:
true

shouldSelectCell

public boolean shouldSelectCell(java.util.EventObject anEvent)
Returns true.
Specified by:
shouldSelectCell in interface javax.swing.CellEditor
Parameters:
e - an event object
Returns:
true

stopCellEditing

public boolean stopCellEditing()
Calls fireEditingStopped and returns true.
Specified by:
stopCellEditing in interface javax.swing.CellEditor
Returns:
true

cancelCellEditing

public void cancelCellEditing()
Calls fireEditingCanceled.
Specified by:
cancelCellEditing in interface javax.swing.CellEditor

addCellEditorListener

public void addCellEditorListener(javax.swing.event.CellEditorListener l)
Adds a CellEditorListener to the listener list.
Specified by:
addCellEditorListener in interface javax.swing.CellEditor
Parameters:
l - the new listener to be added

removeCellEditorListener

public void removeCellEditorListener(javax.swing.event.CellEditorListener l)
Removes a CellEditorListener from the listener list.
Specified by:
removeCellEditorListener in interface javax.swing.CellEditor
Parameters:
l - the listener to be removed

getCellEditorListeners

public javax.swing.event.CellEditorListener[] getCellEditorListeners()
Returns an array of all the CellEditorListeners added to this AbstractCellEditor with addCellEditorListener().
Returns:
all of the CellEditorListeners added or an empty array if no listeners have been added

fireEditingStopped

protected void fireEditingStopped()
Notifies all listeners that have registered interest for notification on this event type. The event instance is created lazily.
See Also:
EventListenerList

fireEditingCanceled

protected void fireEditingCanceled()
Notifies all listeners that have registered interest for notification on this event type. The event instance is created lazily.
See Also:
EventListenerList


Copyright © 2001-2003 Extreme Component, Inc. All rights reserved.