JIDE 3.5.15

com.jidesoft.grid
Interface TableCellEditorRenderer

All Superinterfaces:
CellEditor, TableCellEditor, TableCellRenderer
All Known Implementing Classes:
AbstractTableCellEditorRenderer, ButtonTableCellEditorRenderer, HyperlinkTableCellEditorRenderer

public interface TableCellEditorRenderer
extends TableCellRenderer, TableCellEditor

JTable uses cell renderer and cell editor for cell rendering and editing respectively. For the same cell, the renderer component is usually difference from the editor component. For example, most cell renderer components are JLabel. But to edit a cell, JTextField is usually used as the cell editor component. However, in some cases, maybe we want the same component to be used for both the renderer component and editor component. That's why we introduced TableCellEditorRenderer so that you can use the same component for both renderer and editor.

Why do we want the same component use the same component as both editor and renderer? There are at least two reasons.

This interface introduced two new methods. The first one is createTableCellEditorRendererComponent. This method should always create a new component. It should create the component and doesn't set the value to the component as we also have configureTableCellEditorRendererComponent that should set the value and do more customization if needed, i.e. add a listener. Please make sure you check the component first so that you don't add the same listener multiple times. This method could be called multiple times.

See Also:
AbstractTableCellEditorRenderer, RolloverTableUtils

Method Summary
 void configureTableCellEditorRendererComponent(JTable table, Component editorRendererComponent, boolean forRenderer, Object value, boolean isSelected, boolean hasFocus, int row, int column)
           
 Component createTableCellEditorRendererComponent(JTable table, int row, int column)
           
 
Methods inherited from interface javax.swing.table.TableCellRenderer
getTableCellRendererComponent
 
Methods inherited from interface javax.swing.table.TableCellEditor
getTableCellEditorComponent
 
Methods inherited from interface javax.swing.CellEditor
addCellEditorListener, cancelCellEditing, getCellEditorValue, isCellEditable, removeCellEditorListener, shouldSelectCell, stopCellEditing
 

Method Detail

createTableCellEditorRendererComponent

Component createTableCellEditorRendererComponent(JTable table,
                                                 int row,
                                                 int column)
Parameters:
table - the JTable that is asking the renderer to draw; can be null
row - the row index of the cell being drawn.
column - the column index of the cell being drawn
Returns:
the component for both rendering and editing.

configureTableCellEditorRendererComponent

void configureTableCellEditorRendererComponent(JTable table,
                                               Component editorRendererComponent,
                                               boolean forRenderer,
                                               Object value,
                                               boolean isSelected,
                                               boolean hasFocus,
                                               int row,
                                               int column)
Parameters:
editorRendererComponent - the component that was created by createTableCellEditorRendererComponent.
table - the JTable that is asking the renderer to draw; can be null
forRenderer - true if this component is created for rendering purpose. False if it is for editing purpose.
value - the value of the cell to be rendered. It is up to the specific renderer 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 the selection highlighted; otherwise false
hasFocus - whether the cell has focus. This parameter should always be true for editing purpose but could be true or false for rendering purpose.
row - the row index of the cell being drawn.
column - the column index of the cell being drawn

JIDE 3.5.15