|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JTable
org.tentackle.ui.FormTable
public class FormTable
Extended JTable.
The FormTable provides the following extensions to the standard JTable:
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class javax.swing.JTable |
|---|
JTable.AccessibleJTable, JTable.DropLocation, JTable.PrintMode |
| Nested classes/interfaces inherited from class javax.swing.JComponent |
|---|
JComponent.AccessibleJComponent |
| Nested classes/interfaces inherited from class java.awt.Container |
|---|
Container.AccessibleAWTContainer |
| Nested classes/interfaces inherited from class java.awt.Component |
|---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| Field Summary | |
|---|---|
static int |
CELLTRAVERSAL_AUTOEDIT
|
static int |
CELLTRAVERSAL_COLUMN
|
static int |
CELLTRAVERSAL_NOLINEWRAP
|
static int |
CELLTRAVERSAL_NONE
|
static int |
CELLTRAVERSAL_NOTABLEWRAP
|
static int |
CELLTRAVERSAL_ROW
|
static int |
CELLTRAVERSAL_SKIPNOEDIT
|
static int |
CELLTRAVERSAL_WRAPINLINE
|
static String |
CLICK_ACTION
|
static String |
ENTER_ACTION
|
| Fields inherited from class javax.swing.JComponent |
|---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| Fields inherited from class java.awt.Component |
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
FormTable()
Creates an empty form table. |
|
FormTable(TableModel model)
Creates a formtable for a given data model. |
|
| Method Summary | |
|---|---|
void |
addActionListener(ActionListener listener)
Adds an action listener (usually a double click on a selection). |
void |
addFormTableTraversalListener(FormTableTraversalListener listener)
Adds a traversal listener. |
void |
addListSelectionListener(ListSelectionListener listener)
Adds a selection changed listener. |
void |
changeSelection(int rowIndex,
int columnIndex,
boolean toggle,
boolean extend)
Updates the selection models of the table, depending on the state of the two flags: toggle and extend. |
void |
clearInhibitCellTraversal()
Clears the inhibit of the cell traversal if for some reason set erroneously. |
void |
configureEditors()
Updates the editors. Useful, for example, if the some configuration changed and the editors are fixed (see FormTableEntry.isCellEditorFixed()). |
void |
configureRenderers()
Updates the renderers. Useful, for example, if the some configuration changed and the renderers are fixed (see FormTableEntry.isCellRendererFixed()). |
protected TableColumnModel |
createDefaultColumnModel()
Returns the default column model object, which is a DefaultTableColumnModel. |
void |
createDefaultColumnsFromDefaultModel()
Creates the columns from the default column model |
void |
createDefaultColumnsFromModel()
Creates default columns for the table from the data model using the getColumnCount method
defined in the TableModel interface. |
boolean |
createDefaultColumnsFromPreferences(String prefName,
boolean systemOnly)
Creates the columns from the Preferences and sets the preferred table size according to the column sizes. |
void |
discardCellEvents()
Discards all cell events in the event queue. |
boolean |
editCellAt(int row,
int column,
EventObject e)
Programmatically starts editing the cell at row and
column, if those indices are in the valid range, and
the cell at those indices is editable. |
void |
editCellLater(int row,
int column)
Starts editing at a given row/column. If the cell is already being edited (i.e. |
void |
editingCanceled(ChangeEvent e)
Invoked when editing is canceled. |
void |
editingStopped(ChangeEvent e)
Invoked when editing is finished. |
void |
editNextCellLater()
Edits the next cell according to cellTraversal. |
void |
editNextCellLater(int row,
int column)
Same as editCellLater but advance to next editable cell if given cell is not editable. |
void |
editPreviousCellLater()
Edits the previous cell according to cellTraversal. |
void |
editPreviousCellLater(int row,
int column)
Same as editCellLater but advance to previous editable cell if given cell is not editable |
void |
fireActionPerformed(ActionEvent evt)
Notifies all action listeners. |
void |
fireTraversalRequested(FormTableTraversalEvent evt)
Notifies all traversal listeners that a cell traversal is triggered. |
void |
fireValueChanged(ListSelectionEvent evt)
Notifies all Listeners that the selection has changed. |
char |
getAdjust(int column)
Gets the adjust flag. |
TableCellEditor |
getCellEditor(int row,
int column)
Returns an appropriate editor for the cell specified by row and column. |
Rectangle |
getCellRect(int row,
int column,
boolean includeSpacing)
Returns a rectangle for the cell that lies at the intersection of row and column. |
TableCellRenderer |
getCellRenderer(int row,
int column)
Returns an appropriate renderer for the cell specified by this row and column. |
int |
getCellTraversal()
Sets the cell traversal mode. |
int |
getClickCount()
Gets the number of mouse clicks that caused the current selection. |
int |
getClickCountToAction()
Gets the number of mouse clicks to trigger an action event. |
int |
getClickCountToStart()
Gets the number of clicks to start the full editing mode of a cell. |
TableColumn |
getColumnByModelIndex(int modelIndex)
Gets the table-column according to the data-model index. |
char |
getConvert(int column)
Gets the convert flag. |
DateFormat |
getDateFormat(int column)
Gets the date format. If not set the default format is used from StringHelper. |
DateFormat |
getDateFormat(int column,
boolean asTimestamp)
Gets the date format. If not set the default format is used from StringHelper. |
Rectangle |
getDefaultCellRect(int row,
int column,
boolean includeSpacing)
Refers to the default implementation of getCellRect() because overridden. |
TableCellEditor |
getDefaultEditor(Class columnClass)
Returns the editor to be used when no editor has been set in a TableColumn. |
FormTableEntry |
getEntryAt(int row)
Gets the FormTableEntry at a given (visible) row. |
Color |
getFocusedBackground()
Gets the color for the focus background. |
Color |
getFocusedForeground()
Gets the color for the focus foreground. |
String[] |
getFormat()
Gets the format strings of all columns. |
String |
getFormat(int column)
Gets the format of a column. |
String |
getHelpURL()
Gets the help url. |
int |
getHorizontalAlignment(int column)
Gets the horizontal alignment. |
int |
getMaxRowHeight()
Gets the maximum row-height. |
int |
getMinRowHeight()
Gets the minimum row-height. |
NumberFormat |
getNumberFormat(int column)
Gets the number format. |
Object |
getObjectAt(int row)
Gets the data object that is associated to a given (visible) row. |
String |
getPreferencesName(FormTableEntry entry)
Gets the Preferences-name for this table. The name is built from the classname of the FormTableEntry associated with the table-model plus the name of the table. |
Dimension |
getPreferencesSize()
Gets the preferred size as defined by the preferences. |
Color |
getSelectedBackground()
Gets the color for the selected background. |
Color |
getSelectedForeground()
Gets the color for the selected foreground. |
Object |
getSelectedObject()
Gets the data object at the current row. |
Color |
getUnselectedBackground()
Gets the color for the unselected background. |
Color |
getUnselectedForeground()
Gets the color for the unselected foreground. |
int |
getVerticalAlignment(int column)
Gets the vertical alignment. |
void |
inhibitCellTraversal()
Inhibits cell traversal once. Useful if we should stay in selected field even after Enter-key has been pressed. |
boolean |
isAutoSelect(int column)
Gets the autoselect flag. |
boolean |
isBlankZero(int column)
Gets the blankzero flag. |
boolean |
isCellDragEnabled()
Returns whether cell drag is enabled. |
boolean |
isCellEditable(int row,
int column)
Returns true if the cell at row and column
is editable. |
boolean |
isCellEditorFixed()
Returns whether all cell editors are fixed or may change dynamically. |
boolean |
isCellRectFixed()
Returns whether the cell rectangles are fixed or change dynamically. |
boolean |
isCellRendererFixed()
Returns whether all cell renderers are fixed or may change dynamically. |
boolean |
isChangeable()
Returns whether the cells of this table are editable. |
boolean |
isColumnVisible(int columnIndex)
Returns whether column is visible or not. |
boolean |
isCreateDefaultColumnsFromPreferences()
Returns whether the columns are created according to the preferences. |
boolean |
isDataChanged()
Determines whether some data cell has been changed. |
boolean |
isEditing(int row,
int column)
Returns whether the given cell is currently being edited. |
boolean |
isEnterActionEnabled()
Returns whether ENTER triggers actionPerformed. |
boolean |
isFormTraversable()
Returns whether the table may receive keyboard focus due to a form traversal. |
boolean |
isIgnoreSizeInPreferences()
Returns whether sizes in the preferences are ignored. |
Component |
prepareEditor(TableCellEditor editor,
int row,
int column)
Prepares the editor by querying the data model for the value and selection state of the cell at row, column. |
protected void |
processEvent(AWTEvent e)
Processes events on this container. |
protected boolean |
processKeyBinding(KeyStroke ks,
KeyEvent e,
int condition,
boolean pressed)
Invoked to process the key bindings for ks as the result
of the KeyEvent e. |
protected void |
queueEvent(AWTEvent e)
Queues an Event at the end of the event-queue. |
void |
removeActionListener(ActionListener listener)
Removes an action Listener |
void |
removeFormTableTraversalListener(FormTableTraversalListener listener)
Removes a traversal listener |
void |
removeListSelectionListener(ListSelectionListener listener)
Removes a selection changed Listener. |
void |
savePreferences(String prefName,
boolean system)
Saves the preferences of this table. |
void |
scrollToCell(int row,
int column)
Scrolls to the row, column so that it's visible. |
void |
setAdjust(char adjust)
Sets the adjust flag for all columns. |
void |
setAdjust(int column,
char adjust)
Sets the adjust flag. |
void |
setAutoSelect(boolean autoSelect)
Sets autoSelect for all columns. |
void |
setAutoSelect(int column,
boolean autoSelect)
Sets the autoselect flag. |
void |
setBlankZero(boolean blankZero)
Sets the blankzero flag for all columns. |
void |
setBlankZero(int column,
boolean blankZero)
Sets the blankzero flag. |
void |
setCellDragEnabled(boolean cellDragEnabled)
Enables or disables cell dragging. The default TransferHandler in MetalLookAndFeel drags cells only if column-selection is allowed. |
void |
setCellEditorFixed(boolean cellEditorFixed)
Sets whether all cell editors are fixed or may change dynamically. |
void |
setCellRectFixed(boolean cellRectFixed)
Sets whether the cell rectangles are fixed or change dynamically. |
void |
setCellRendererFixed(boolean cellRendererFixed)
Sets whether all cell renderers are fixed or may change dynamically. |
void |
setCellTraversal(int mode)
Sets the cell traversal mode. |
void |
setChangeable(boolean changeable)
Sets all cells of the table editable/not-editable. |
void |
setClickCountToAction(int clicks)
Sets the number of mouse clicks to trigger an action event. |
void |
setClickCountToStart(int clicks)
Sets the number of clicks to start the full editing mode of a cell. |
void |
setColumnVisible(int columnIndex,
boolean visible)
Hides or displays a column. |
void |
setConvert(char convert)
Sets the convert flag for all columns. |
void |
setConvert(int column,
char convert)
Sets the convert flag. |
void |
setCreateDefaultColumnsFromPreferences(boolean createDefaultColumnsFromPreferences)
Sets whether the columns are created according to the preferences. |
void |
setDefaultEditor(Class<?> columnClass,
TableCellEditor editor)
Sets a default cell editor to be used if no editor has been set in a TableColumn. |
void |
setEnterActionEnabled(boolean enableEnterAction)
Enables/disables ENTER to trigger actionPerformed if row is selected. |
void |
setFocusedBackground(Color c)
Sets the color for the focus background. |
void |
setFocusedForeground(Color c)
Sets the color for the focus foreground. |
void |
setFormat(int column,
String fmt)
Sets the format for a given column. |
void |
setFormat(String[] fmt)
Sets the format for all columns. |
void |
setFormTraversable(boolean formTraversable)
Sets whether the table may receive keyboard focus due to a form traversal. |
void |
setHelpURL(String helpURL)
Sets the help url. |
void |
setHorizontalAlignment(int align)
Sets the horizontal alignment for all columns. |
void |
setHorizontalAlignment(int column,
int align)
Sets the horizontal alignment (not to be mixed up with ADJUST_...) |
void |
setIgnoreSizeInPreferences(boolean ignoreSizeInPreferences)
Returns whether sizes in the preferences are ignored. In apps with fixed window sizes (i.e. |
void |
setMaxRowHeight(int maxRowHeight)
Sets the maximum row-height. |
void |
setMinRowHeight(int minRowHeight)
Sets the minimum row-height. |
void |
setModel(TableModel dataModel)
Sets the data model for this table to newModel and registers
with it for listener notifications from the new data model. |
void |
setRowHeight(int rowHeight)
Sets the height, in pixels, of all cells to rowHeight,
revalidates, and repaints. |
void |
setRowHeight(int row,
int rowHeight)
Sets the height for row to rowHeight,
revalidates, and repaints. |
void |
setSelectedBackground(Color c)
Sets the color for the selected background. |
void |
setSelectedColumn(int col)
Sets the selected column. |
void |
setSelectedColumns(int[] cols)
Sets the col-selection for an array of columns. |
void |
setSelectedForeground(Color c)
Sets the color for the selected foreground. |
void |
setSelectedRow(int row)
Sets the row-selection (single row) (getSelectedRow is implemented in JTable but not setSelectedRow, for whatever reason) |
void |
setSelectedRows(int[] rows)
Sets the row-selection for an array of rows. |
void |
setUnselectedBackground(Color c)
Sets the color for the unselected background. |
void |
setUnselectedForeground(Color c)
Sets the color for the unselected foreground. |
void |
setVerticalAlignment(int align)
Sets the vertical alignment for all columns. Works only if a tentackle-plaf is used. |
void |
setVerticalAlignment(int column,
int align)
Sets the vertical alignment. Works only if a tentackle-plaf is used. |
void |
valueChanged(ListSelectionEvent evt)
Invoked when the row selection changes. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String CLICK_ACTION
public static final String ENTER_ACTION
public static final int CELLTRAVERSAL_NONE
public static final int CELLTRAVERSAL_COLUMN
public static final int CELLTRAVERSAL_ROW
public static final int CELLTRAVERSAL_NOLINEWRAP
public static final int CELLTRAVERSAL_WRAPINLINE
public static final int CELLTRAVERSAL_NOTABLEWRAP
public static final int CELLTRAVERSAL_SKIPNOEDIT
public static final int CELLTRAVERSAL_AUTOEDIT
| Constructor Detail |
|---|
public FormTable(TableModel model)
model - the data modelpublic FormTable()
setModel(javax.swing.table.TableModel).
| Method Detail |
|---|
public void setDefaultEditor(Class<?> columnClass,
TableCellEditor editor)
TableColumn. If no editing is required in a table, or a
particular column in a table, uses the isCellEditable
method in the TableModel interface to ensure that this
JTable will not start an editor in these columns.
If editor is null, removes the default editor for this
column class.
Overridden cause of setClickCountToStart(int).
setDefaultEditor in class JTablecolumnClass - set the default cell editor for this columnClasseditor - default cell editor to be used for this columnClassTableModel.isCellEditable(int, int),
JTable.getDefaultEditor(java.lang.Class>),
JTable.setDefaultRenderer(java.lang.Class>, javax.swing.table.TableCellRenderer)public String getHelpURL()
public void setHelpURL(String helpURL)
helpURL - the help url, null if nonepublic boolean isFormTraversable()
public void setFormTraversable(boolean formTraversable)
formTraversable - true if can receive focus, default is false (focus only by mouse-click)public boolean isDataChanged()
public String getPreferencesName(FormTableEntry entry)
entry - the formtable entry
public boolean createDefaultColumnsFromPreferences(String prefName,
boolean systemOnly)
prefName - is the name of the Preferences-nodesystemOnly - is true if take from SystemPreferences only. Otherwise
system is only consulted if there is no user setting.
public Dimension getPreferencesSize()
public boolean isCreateDefaultColumnsFromPreferences()
public void setCreateDefaultColumnsFromPreferences(boolean createDefaultColumnsFromPreferences)
createDefaultColumnsFromPreferences - true if createDefaultColumnsFromModel() should invoke createDefaultColumnsFromPreferences()public void createDefaultColumnsFromModel()
getColumnCount method
defined in the TableModel interface.
Clears any existing columns before creating the new columns based on information from the model.
Overridden to create the columns according to the Preferences if the tableModel is an AbstractFormTableModel (and Preferences exist for that table).
createDefaultColumnsFromModel in class JTableJTable.getAutoCreateColumnsFromModel()public void createDefaultColumnsFromDefaultModel()
public void savePreferences(String prefName,
boolean system)
throws BackingStoreException
prefName - the name of the Preferences-nodesystem - true if store to system-preferences, else store in userprefs
BackingStoreException - if save failedpublic void setSelectedRow(int row)
row - the row numberpublic void setSelectedRows(int[] rows)
rows - the rowspublic void setSelectedColumn(int col)
col - the column numberpublic void setSelectedColumns(int[] cols)
cols - the columnspublic FormTableEntry getEntryAt(int row)
row - the row number
public Object getObjectAt(int row)
row - the row number
public Object getSelectedObject()
protected void queueEvent(AWTEvent e)
e - the eventprotected void processEvent(AWTEvent e)
ContainerEvent, it invokes the
processContainerEvent method, else it invokes
its superclass's processEvent.
Note that if the event parameter is null
the behavior is unspecified and may result in an
exception.
Overridden to handle cell-traversal events
processEvent in class Containere - the eventComponent.processComponentEvent(java.awt.event.ComponentEvent),
Component.processFocusEvent(java.awt.event.FocusEvent),
Component.processKeyEvent(java.awt.event.KeyEvent),
Component.processMouseEvent(java.awt.event.MouseEvent),
Component.processMouseMotionEvent(java.awt.event.MouseEvent),
Component.processInputMethodEvent(java.awt.event.InputMethodEvent),
Component.processHierarchyEvent(java.awt.event.HierarchyEvent),
Component.processMouseWheelEvent(java.awt.event.MouseWheelEvent)protected TableColumnModel createDefaultColumnModel()
DefaultTableColumnModel. A subclass can override this
method to return a different column model object.
Overridden to use FormTableColumnModel instead of DefaultTableColumnModel. This is necessary to allow setVisible() of a column.
createDefaultColumnModel in class JTableDefaultTableColumnModel
public void setColumnVisible(int columnIndex,
boolean visible)
columnIndex - the column index according to the data-model.visible - true if column is made visible, false if invisiblepublic boolean isColumnVisible(int columnIndex)
columnIndex - the column index according to the data-model.
protected boolean processKeyBinding(KeyStroke ks,
KeyEvent e,
int condition,
boolean pressed)
ks as the result
of the KeyEvent e. This obtains
the appropriate InputMap,
gets the binding, gets the action from the ActionMap,
and then (if the action is found and the component
is enabled) invokes notifyAction to notify the action.
Overridden to implement enhanced keyboard handling.
processKeyBinding in class JTableks - the KeyStroke queriede - the KeyEventcondition - one of the following values:
pressed - true if the key is pressed
public void setSelectedForeground(Color c)
c - the foreground colorpublic Color getSelectedForeground()
public void setSelectedBackground(Color c)
c - the background colorpublic Color getSelectedBackground()
public void setUnselectedForeground(Color c)
c - the unselected foreground colorpublic Color getUnselectedForeground()
public void setUnselectedBackground(Color c)
c - the background colorpublic Color getUnselectedBackground()
public void setFocusedForeground(Color c)
c - the focus foreground colorpublic Color getFocusedForeground()
public void setFocusedBackground(Color c)
c - the focus background colorpublic Color getFocusedBackground()
public boolean isEditing(int row,
int column)
row - the row indexcolumn - the column index
public void editCellLater(int row,
int column)
Notice that the edit-request is queued!
row - the row indexcolumn - the column index
public void editNextCellLater(int row,
int column)
Notice that the edit-request is queued!
row - the row indexcolumn - the column indexeditCellLater(int, int)
public void editPreviousCellLater(int row,
int column)
Notice that the edit-request is queued!
row - the row indexcolumn - the column indexeditCellLater(int, int)public void editNextCellLater()
Notice that the edit-request is queued!
public void editPreviousCellLater()
Notice that the edit-request is queued!
public boolean editCellAt(int row,
int column,
EventObject e)
row and
column, if those indices are in the valid range, and
the cell at those indices is editable.
To prevent the JTable from
editing a particular table, column or cell value, return false from
the isCellEditable method in the TableModel
interface.
Overridden to fix certain flaws in JTable.
editCellAt in class JTablerow - the row to be editedcolumn - the column to be editede - event to pass into shouldSelectCell;
note that as of Java 2 platform v1.2, the call to
shouldSelectCell is no longer made
public void editingStopped(ChangeEvent e)
Application code will not use these methods explicitly, they are used internally by JTable.
Overridden to catch the last key for generating CellTraversalEvents
editingStopped in interface CellEditorListenereditingStopped in class JTablee - the event receivedCellEditorListenerpublic void editingCanceled(ChangeEvent e)
javax.swing.JTableApplication code will not use these methods explicitly, they are used internally by JTable.
editingCanceled in interface CellEditorListenereditingCanceled in class JTablee - the event receivedCellEditorListenerpublic void inhibitCellTraversal()
public void clearInhibitCellTraversal()
public void discardCellEvents()
public void setModel(TableModel dataModel)
newModel and registers
with it for listener notifications from the new data model.
Overridden to setup the formatting, renderers and editors.
setModel in class JTabledataModel - the new data source for this tableJTable.getModel()public void configureRenderers()
FormTableEntry.isCellRendererFixed()).
Does nothing if the current model is not an AbstractFormTableModel.
public void configureEditors()
FormTableEntry.isCellEditorFixed()).
Does nothing if the current model is not an AbstractFormTableModel.
public TableColumn getColumnByModelIndex(int modelIndex)
modelIndex - the column index according to the data model
public Rectangle getDefaultCellRect(int row,
int column,
boolean includeSpacing)
row - the row indexcolumn - the column indexincludeSpacing - false to return the true cell bounds
JTable.getCellRect(int, int, boolean)
public Rectangle getCellRect(int row,
int column,
boolean includeSpacing)
row and column.
If includeSpacing is true then the value returned
has the full height and width of the row and column
specified. If it is false, the returned rectangle is inset by the
intercell spacing to return the true bounds of the rendering or
editing component as it will be set during rendering.
If the column index is valid but the row index is less
than zero the method returns a rectangle with the
y and height values set appropriately
and the x and width values both set
to zero. In general, when either the row or column indices indicate a
cell outside the appropriate range, the method returns a rectangle
depicting the closest edge of the closest cell that is within
the table's range. When both row and column indices are out
of range the returned rectangle covers the closest
point of the closest cell.
In all cases, calculations that use this method to calculate
results along one axis will not fail because of anomalies in
calculations along the other axis. When the cell is not valid
the includeSpacing parameter is ignored.
Overridden to implement cell merging.
getCellRect in class JTablerow - the row index where the desired cell
is locatedcolumn - the column index where the desired cell
is located in the display; this is not
necessarily the same as the column index
in the data model for the table; the
JTable.convertColumnIndexToView(int)
method may be used to convert a data
model column index to a display
column indexincludeSpacing - if false, return the true cell bounds -
computed by subtracting the intercell
spacing from the height and widths of
the column and row models
row,columnJTable.getIntercellSpacing()
public void changeSelection(int rowIndex,
int columnIndex,
boolean toggle,
boolean extend)
toggle and extend. Most changes
to the selection that are the result of keyboard or mouse events received
by the UI are channeled through this method so that the behavior may be
overridden by a subclass. Some UIs may need more functionality than
this method provides, such as when manipulating the lead for discontiguous
selection, and may not call into this method for some selection changes.
This implementation uses the following conventions:
toggle: false, extend: false.
Clear the previous selection and ensure the new cell is selected.
toggle: false, extend: true.
Extend the previous selection from the anchor to the specified cell,
clearing all other selections.
toggle: true, extend: false.
If the specified cell is selected, deselect it. If it is not selected, select it.
toggle: true, extend: true.
Apply the selection state of the anchor to all cells between it and the
specified cell.
Overridden to implement cell merging.
changeSelection in class JTablerowIndex - affects the selection at rowcolumnIndex - affects the selection at columntoggle - see description aboveextend - if true, extend the current selectionpublic void setCellTraversal(int mode)
mode - the cell traversal mode, one or more of CELLTRAVERSAL_...public int getCellTraversal()
public void addListSelectionListener(ListSelectionListener listener)
listener - the listener to addpublic void removeListSelectionListener(ListSelectionListener listener)
listener - the listener to removepublic void fireValueChanged(ListSelectionEvent evt)
evt - the selection eventpublic void valueChanged(ListSelectionEvent evt)
Overridden to fire the formtable listeners.
valueChanged in interface ListSelectionListenervalueChanged in class JTableevt - the selection eventListSelectionListenerpublic void addFormTableTraversalListener(FormTableTraversalListener listener)
listener - the listener to addpublic void removeFormTableTraversalListener(FormTableTraversalListener listener)
listener - the listener to remove
public void fireTraversalRequested(FormTableTraversalEvent evt)
throws FormTableTraversalVetoException
evt - the traversal event
FormTableTraversalVetoException - if traversal vetoedpublic void addActionListener(ActionListener listener)
listener - the listener to addpublic void removeActionListener(ActionListener listener)
listener - the listener to removepublic void fireActionPerformed(ActionEvent evt)
evt - the action eventpublic int getClickCount()
public void setClickCountToAction(int clicks)
clicks - the number of clicks, default is 2.public int getClickCountToAction()
public void setEnterActionEnabled(boolean enableEnterAction)
Notice that enabling ENTER action is only meaningful if the table is not editable and celltraversal is turned off.
enableEnterAction - true to enable, default is falsepublic boolean isEnterActionEnabled()
public void setClickCountToStart(int clicks)
clicks - the number of clicks, default is 2public int getClickCountToStart()
public void setChangeable(boolean changeable)
changeable - true if cells are editableisCellEditable(int, int)public boolean isChangeable()
isCellEditable(int, int)
public boolean isCellEditable(int row,
int column)
row and column
is editable. Otherwise, invoking setValueAt on the cell
will have no effect.
Note: The column is specified in the table view's display
order, and not in the TableModel's column
order. This is an important distinction because as the
user rearranges the columns in the table,
the column at a given index in the view will change.
Meanwhile the user's actions never affect the model's
column ordering.
Overridden to implement the changeable attribute.
isCellEditable in class JTablerow - the row whose value is to be queriedcolumn - the column whose value is to be queried
JTable.setValueAt(java.lang.Object, int, int)
public void setFormat(int column,
String fmt)
column - the column indexfmt - public void setFormat(String[] fmt)
fmt - the format array (size must match the number of columns)public String getFormat(int column)
column - the column index
public String[] getFormat()
public void setAutoSelect(int column,
boolean autoSelect)
column - the column indexautoSelect - true to enable autoselect, default is falsepublic void setAutoSelect(boolean autoSelect)
autoSelect - true to enable autoselect, default is falsepublic boolean isAutoSelect(int column)
column - the column index
public void setBlankZero(int column,
boolean blankZero)
column - the column indexblankZero - true to enable zero suppression, default is falsepublic void setBlankZero(boolean blankZero)
blankZero - true to enable zero suppression, default is falsepublic boolean isBlankZero(int column)
column - the column index
public void setConvert(int column,
char convert)
column - the column indexconvert - the character conversion mode, default is FormField.CONVERT_NONEpublic void setConvert(char convert)
convert - the character conversion mode, default is FormField.CONVERT_NONEpublic char getConvert(int column)
column - the column index
public void setAdjust(int column,
char adjust)
column - the column indexadjust - the adjustment mode, default is FormField.ADJUST_TRIMpublic void setAdjust(char adjust)
adjust - the adjustment mode, default is FormField.ADJUST_TRIMpublic char getAdjust(int column)
column - the column index
public void setHorizontalAlignment(int column,
int align)
column - the column indexalign - the alignmentJLabel.setHorizontalAlignment(int)public void setHorizontalAlignment(int align)
align - the alignmentJLabel.setHorizontalAlignment(int)public int getHorizontalAlignment(int column)
column - the column index
JLabel.setHorizontalAlignment(int)
public void setVerticalAlignment(int column,
int align)
column - the column indexalign - the alignmentJLabel.setVerticalAlignment(int)public void setVerticalAlignment(int align)
align - the alignmentJLabel.setVerticalAlignment(int)public int getVerticalAlignment(int column)
column - the column index
JLabel.setHorizontalAlignment(int)
public DateFormat getDateFormat(int column,
boolean asTimestamp)
column - the column indexasTimestamp - true if default format to use is for timestamps
StringHelper.shortDateFormat,
StringHelper.shortTimestampFormatpublic DateFormat getDateFormat(int column)
column - the column index
StringHelper.shortDateFormatpublic NumberFormat getNumberFormat(int column)
column - the column index
StringHelper.integerPatternpublic void setMinRowHeight(int minRowHeight)
minRowHeight - the minimum row height in pixels, 0 = no limitpublic int getMinRowHeight()
public void setMaxRowHeight(int maxRowHeight)
maxRowHeight - the minimum row height in pixels, 0 = no limitpublic int getMaxRowHeight()
public void setRowHeight(int row,
int rowHeight)
row to rowHeight,
revalidates, and repaints. The height of the cells in this row
will be equal to the row height minus the row margin.
Overridden to check against min/max-rowheights
setRowHeight in class JTablerow - the row whose height is being
changedrowHeight - new row height, in pixelspublic void setRowHeight(int rowHeight)
rowHeight,
revalidates, and repaints.
The height of the cells will be equal to the row height minus
the row margin.
Overridden to check against min/max-rowheights
setRowHeight in class JTablerowHeight - new row heightJTable.getRowHeight()
public void scrollToCell(int row,
int column)
row - the row indexcolumn - the column indexJComponent.scrollRectToVisible(java.awt.Rectangle)public boolean isIgnoreSizeInPreferences()
public void setIgnoreSizeInPreferences(boolean ignoreSizeInPreferences)
ignoreSizeInPreferences - true if don't setPreferredSize, default is false.public boolean isCellEditorFixed()
public void setCellEditorFixed(boolean cellEditorFixed)
cellEditorFixed - true if cell editors don't change dynamically (default)public boolean isCellRendererFixed()
public void setCellRendererFixed(boolean cellRendererFixed)
cellRendererFixed - true if cell renderers don't change dynamically (default)public boolean isCellRectFixed()
public void setCellRectFixed(boolean cellRectFixed)
cellRectFixed - true if cells don't change sizes dynamically (default)
public TableCellRenderer getCellRenderer(int row,
int column)
TableColumn for this column has a non-null
renderer, returns that. If not, finds the class of the data in
this column (using getColumnClass)
and returns the default renderer for this type of data.
Note: Throughout the table package, the internal implementations always use this method to provide renderers so that this default behavior can be safely overridden by a subclass.
Overridden to invoke getCellRenderer in FormTableEntry if the renderer is not fixed.
getCellRenderer in class JTablerow - the row of the cell to render, where 0 is the first rowcolumn - the column of the cell to render,
where 0 is the first column
null
returns the default renderer
for this type of objectDefaultTableCellRenderer,
TableColumn.setCellRenderer(javax.swing.table.TableCellRenderer),
JTable.setDefaultRenderer(java.lang.Class>, javax.swing.table.TableCellRenderer)
public TableCellEditor getCellEditor(int row,
int column)
row and column. If the
TableColumn for this column has a non-null editor,
returns that. If not, finds the class of the data in this
column (using getColumnClass)
and returns the default editor for this type of data.
Note: Throughout the table package, the internal implementations always use this method to provide editors so that this default behavior can be safely overridden by a subclass.
Overridden to invoke getCellEditor in FormTableEntry if the editor is not fixed.
getCellEditor in class JTablerow - the row of the cell to edit, where 0 is the first rowcolumn - the column of the cell to edit,
where 0 is the first column
null return the default editor for
this type of cellDefaultCellEditorpublic TableCellEditor getDefaultEditor(Class columnClass)
TableColumn. During the editing of cells the editor is fetched from
a Hashtable of entries according to the class of the cells in the column. If
there is no entry for this columnClass the method returns
the entry for the most specific superclass. The JTable installs entries
for Object, Number, and Boolean, all of which can be modified
or replaced.
Overridden to return the FormFieldEditor for a String in case the column-class isn't known yet. In this case a column-class of 'Object' is passed which we will translate to a String right here because it will be done by JTable's implementation anyway (see GenericEditor). The GenericEditor should be avoided because it isn't aware of all the FormTable-extensions. A couple of things won't work such as celltraversal, formatting, etc... If this is not what you want, please override getColumnClass in the FormTableEntry and provide the correct class for columns that may be initially null.
getDefaultEditor in class JTablecolumnClass - return the default cell editor for this columnClass
JTable.setDefaultEditor(java.lang.Class>, javax.swing.table.TableCellEditor),
JTable.getColumnClass(int)public boolean isCellDragEnabled()
public void setCellDragEnabled(boolean cellDragEnabled)
cellDragEnabled - true to enable cell drag (default), false for row drag
public Component prepareEditor(TableCellEditor editor,
int row,
int column)
row, column.
Note: Throughout the table package, the internal implementations always use this method to prepare editors so that this default behavior can be safely overridden by a subclass.
overridden to fix the bug in JTable that editable ComboBoxes don't return the focus to the table. Furthermore transferFocusBackward is implemented here to allow walk back in editing cells with Shift-ENTER.
prepareEditor in class JTableeditor - the TableCellEditor to set uprow - the row of the cell to edit,
where 0 is the first rowcolumn - the column of the cell to edit,
where 0 is the first column
Component being edited
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||