|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.swing.AbstractCellEditor | +--org.gjt.btools.gui.component.LongStringRenderer
A component used to represent very long strings in table cells. A standard label is inadequate for displaying very long strings because there is no way to scroll across to see beyond the initial portion that fits into the table cell. This component provides a button that brings up a dialog displaying the full cell contents.
This component is actually implemented both as a cell renderer and a cell editor. It cannot be used to edit table values, but because the user must interact directly with this component, it must be registered both as a renderer and an editor for the appropriate table cells, and the table model must declare that such cells be editable. No change will ever be made to the underlying table data.
The renderer is a simple label that will only display the leftmost portion of the cell contents. When the user clicks on such a cell, the editor appears. The editor consists of a read-only text edit field that fills most of the table cell (this field can be scrolled and selections can be made) and a button at the very right hand end that brings up a dialog displaying the full cell contents. Such dialogs are not model and can be left on screen as long as desired (so for instance multiple cell contents can be viewed and compared). The cell contents are copied to the dialog and so the dialog may remain on screen well after the table has been destroyed.
The table cells may contain any objects; the method Object.toString() will be used to convert them into strings for display. The method for choosing a title for the corresponding content viewer dialog can be changed by overriding method getDialogTitle(). The default implementation simply uses the corresponding column heading in the table.
getDialogTitle(javax.swing.JTable, java.lang.Object, int, int)
,
Serialized FormField Summary |
Fields inherited from class javax.swing.AbstractCellEditor |
changeEvent, listenerList |
Constructor Summary | |
LongStringRenderer()
Creates a new long string renderer. |
|
LongStringRenderer(int clicksToEdit)
Creates a new long string renderer. |
Method Summary | |
java.lang.Object |
getCellEditorValue()
Returns the value of the table cell being edited. |
java.lang.String |
getDialogTitle(javax.swing.JTable table,
java.lang.Object value,
int row,
int column)
Returns the title to use for the dialog that will display the full contents of the given cell. |
java.awt.Component |
getTableCellEditorComponent(javax.swing.JTable table,
java.lang.Object value,
boolean isSelected,
int row,
int column)
Returns the component that does the pseudo-editing. |
java.awt.Component |
getTableCellRendererComponent(javax.swing.JTable table,
java.lang.Object value,
boolean isSelected,
boolean hasFocus,
int row,
int column)
Returns the component that does the rendering. |
boolean |
isCellEditable(java.util.EventObject e)
Determines if the given event is cause to start editing the table cell. |
boolean |
shouldSelectCell(java.util.EventObject e)
Prepares the component for editing as requested by the given event. |
Methods inherited from class javax.swing.AbstractCellEditor |
addCellEditorListener, cancelCellEditing, fireEditingCanceled, fireEditingStopped, getCellEditorListeners, removeCellEditorListener, 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, removeCellEditorListener, stopCellEditing |
Constructor Detail |
public LongStringRenderer()
public LongStringRenderer(int clicksToEdit)
clicksToEdit
- the number of mouse clicks required for
cell editing to begin.Method Detail |
public java.lang.String getDialogTitle(javax.swing.JTable table, java.lang.Object value, int row, int column)
table
- the table containing the given cell.value
- the value stored in the given cell.row
- the row of the given cell in the table.column
- the column of the given cell in the table.
public java.awt.Component getTableCellRendererComponent(javax.swing.JTable table, java.lang.Object value, boolean isSelected, boolean hasFocus, int row, int column)
getTableCellRendererComponent
in interface javax.swing.table.TableCellRenderer
table
- the table in which a cell is being rendered.value
- the value of the table cell being rendered.isSelected
- whether or not the table cell is currently
selected.hasFocus
- whether or not the table cell currently has the
focus.row
- the row of the table cell being rendered.column
- the column of the table cell being rendered.
public java.awt.Component getTableCellEditorComponent(javax.swing.JTable table, java.lang.Object value, boolean isSelected, int row, int column)
getTableCellEditorComponent
in interface javax.swing.table.TableCellEditor
table
- the table in which a cell is being edited.value
- the value of the table cell being edited.isSelected
- whether or not the table cell is currently
selected.row
- the row of the table cell being edited.column
- the column of the table cell being edited.
public boolean isCellEditable(java.util.EventObject e)
isCellEditable
in interface javax.swing.CellEditor
isCellEditable
in class javax.swing.AbstractCellEditor
e
- the event under consideration.
public java.lang.Object getCellEditorValue()
getCellEditorValue
in interface javax.swing.CellEditor
public boolean shouldSelectCell(java.util.EventObject e)
shouldSelectCell
in interface javax.swing.CellEditor
shouldSelectCell
in class javax.swing.AbstractCellEditor
e
- the event that caused editing to begin.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |