MDateSelector

mseries.ui
Class MDateCellEditor

java.lang.Object
  extended by javax.swing.AbstractCellEditor
      extended by mseries.ui.MDateCellEditor
All Implemented Interfaces:
Serializable, CellEditor, TableCellEditor, TableCellRenderer

public class MDateCellEditor
extends AbstractCellEditor
implements TableCellEditor, TableCellRenderer

A simple example of MDateEntryField used as a table cell editor and table cell renderer. It implements both interfaces but the same instance can not be used as both the renderer and the editor. It is safest to use two instances for each cell. As a renderer all the component gives is the date formatting and the button which when clicked invokes the editor which looks the same. A simple date formatting textfield would work equally well as the renderer as Swing itself replaces the renderer with the editor when the cell is clicked and vice-versa when editing is finished.

See Also:
Serialized Form

Field Summary
 MDateEntryField comp
           
 
Fields inherited from class javax.swing.AbstractCellEditor
changeEvent, listenerList
 
Constructor Summary
MDateCellEditor(DateFormat formatter)
          Constructs the editor using the date formatter passed.
MDateCellEditor(String format)
           
 
Method Summary
protected  void configureEditor()
          This method can be used to configure the MDateEntryField that is used as the cell editor component.
 Object getCellEditorValue()
           
 Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column)
          This method makes the component an editor
 Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
          This method makes the component a renderer
 void setConstraints(MDateSelectorConstraints c)
          Passes the constraints object to the field that does the editing.
 
Methods inherited from class javax.swing.AbstractCellEditor
addCellEditorListener, cancelCellEditing, fireEditingCanceled, fireEditingStopped, getCellEditorListeners, isCellEditable, removeCellEditorListener, shouldSelectCell, stopCellEditing
 
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, cancelCellEditing, isCellEditable, removeCellEditorListener, shouldSelectCell, stopCellEditing
 

Field Detail

comp

public MDateEntryField comp
Constructor Detail

MDateCellEditor

public MDateCellEditor(DateFormat formatter)
Constructs the editor using the date formatter passed.

Parameters:
formatter - a DateFormat object to use for displaying the date

MDateCellEditor

public MDateCellEditor(String format)
Method Detail

getTableCellEditorComponent

public Component getTableCellEditorComponent(JTable table,
                                             Object value,
                                             boolean isSelected,
                                             int row,
                                             int column)
This method makes the component an editor

Specified by:
getTableCellEditorComponent in interface TableCellEditor

getTableCellRendererComponent

public Component getTableCellRendererComponent(JTable table,
                                               Object value,
                                               boolean isSelected,
                                               boolean hasFocus,
                                               int row,
                                               int column)
This method makes the component a renderer

Specified by:
getTableCellRendererComponent in interface TableCellRenderer

getCellEditorValue

public Object getCellEditorValue()
Specified by:
getCellEditorValue in interface CellEditor

configureEditor

protected void configureEditor()
This method can be used to configure the MDateEntryField that is used as the cell editor component. In the constructor this method is called after the format is set and after border is nullified. Thus it is best to only configure a constrainst object here and use it to configure the editing field.

See Also:
MDateEntryField, MDateSelectorConstraints

setConstraints

public void setConstraints(MDateSelectorConstraints c)
Passes the constraints object to the field that does the editing.

Parameters:
c - a constraints object that can configure the pull down

MDateSelector

Copyright © 2001-2007 M Newstead. All Rights Reserved.