|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.AbstractCellEditor
uk.ac.ic.doc.automed.editor.TextEditor
public class TextEditor
Cell editor class for cache table. This class uses a combination of a
TextArea
and a JScrollPane
to construct a flexible scrollable text box that
appears whenever a cell's value is too long to fit in a table's column
To use this class, all you need to do is to initialise a JTable
object
and invoke the following method:
myTable.setDefaultEditor(Object.class, new TextEditor(myTable));
if you would like to use the same editor for all columns. Alternatively,
you could use myColumn.setCellEditor(new TextEditor(myTable))
to
use the editor for a specific table column.
Field Summary | |
---|---|
private javax.swing.JScrollPane |
_scrollPane
|
private javax.swing.JTable |
_table
|
private javax.swing.JTextArea |
_textEditor
|
Fields inherited from class javax.swing.AbstractCellEditor |
---|
changeEvent, listenerList |
Constructor Summary | |
---|---|
TextEditor()
|
|
TextEditor(javax.swing.JTable table)
|
Method Summary | |
---|---|
static int |
calculateCellValueLength(java.awt.Component c,
java.lang.String value)
Get the estimated length of a text string painted on a component |
java.lang.Object |
getCellEditorValue()
Implement one method of AbstractCellEditor adapter class |
protected static javax.swing.JScrollPane |
getScrollPane(javax.swing.JTextArea textEditor)
Initialises the scroll pane for the text area |
protected java.lang.String |
getSelectedValue(javax.swing.JTable table)
Get the selected cell value |
java.awt.Component |
getTableCellEditorComponent(javax.swing.JTable table,
java.lang.Object value,
boolean isSelected,
int row,
int column)
Implement TableCellEditor interface.Return the actual text editor to use in the selected table cell. |
protected static javax.swing.JTextArea |
getTextArea(java.lang.String value,
boolean editable,
boolean wrapped,
int width,
int height)
Initialises the text area to use |
protected void |
resetEditor(javax.swing.JTextArea textEditor,
javax.swing.JCheckBox chkWrapped)
Give default settings to text area |
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 |
---|
private javax.swing.JTextArea _textEditor
private javax.swing.JScrollPane _scrollPane
private javax.swing.JTable _table
Constructor Detail |
---|
public TextEditor()
public TextEditor(javax.swing.JTable table)
Method Detail |
---|
protected static javax.swing.JTextArea getTextArea(java.lang.String value, boolean editable, boolean wrapped, int width, int height)
protected static javax.swing.JScrollPane getScrollPane(javax.swing.JTextArea textEditor)
protected void resetEditor(javax.swing.JTextArea textEditor, javax.swing.JCheckBox chkWrapped)
public java.lang.Object getCellEditorValue()
AbstractCellEditor
adapter class
getCellEditorValue
in interface javax.swing.CellEditor
public java.awt.Component getTableCellEditorComponent(javax.swing.JTable table, java.lang.Object value, boolean isSelected, int row, int column)
TableCellEditor
interface.
getTableCellEditorComponent
in interface javax.swing.table.TableCellEditor
protected java.lang.String getSelectedValue(javax.swing.JTable table)
public static int calculateCellValueLength(java.awt.Component c, java.lang.String value)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |