org.tentackle.ui
Class FormTable

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JTable
                  extended by org.tentackle.ui.FormTable
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, EventListener, Accessible, CellEditorListener, ListSelectionListener, RowSorterListener, TableColumnModelListener, TableModelListener, Scrollable
Direct Known Subclasses:
PrintTable

public class FormTable
extends JTable

Extended JTable.

The FormTable provides the following extensions to the standard JTable:

Author:
harald
See Also:
Serialized Form

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.JTable
AUTO_RESIZE_ALL_COLUMNS, AUTO_RESIZE_LAST_COLUMN, AUTO_RESIZE_NEXT_COLUMN, AUTO_RESIZE_OFF, AUTO_RESIZE_SUBSEQUENT_COLUMNS, autoCreateColumnsFromModel, autoResizeMode, cellEditor, cellSelectionEnabled, columnModel, dataModel, defaultEditorsByColumnClass, defaultRenderersByColumnClass, editingColumn, editingRow, editorComp, gridColor, preferredViewportSize, rowHeight, rowMargin, rowSelectionAllowed, selectionBackground, selectionForeground, selectionModel, showHorizontalLines, showVerticalLines, tableHeader
 
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 javax.swing.JTable
addColumn, addColumnSelectionInterval, addNotify, addRowSelectionInterval, clearSelection, columnAdded, columnAtPoint, columnMarginChanged, columnMoved, columnRemoved, columnSelectionChanged, configureEnclosingScrollPane, convertColumnIndexToModel, convertColumnIndexToView, convertRowIndexToModel, convertRowIndexToView, createDefaultDataModel, createDefaultEditors, createDefaultRenderers, createDefaultSelectionModel, createDefaultTableHeader, createScrollPaneForTable, doLayout, editCellAt, getAccessibleContext, getAutoCreateColumnsFromModel, getAutoCreateRowSorter, getAutoResizeMode, getCellEditor, getCellSelectionEnabled, getColumn, getColumnClass, getColumnCount, getColumnModel, getColumnName, getColumnSelectionAllowed, getDefaultRenderer, getDragEnabled, getDropLocation, getDropMode, getEditingColumn, getEditingRow, getEditorComponent, getFillsViewportHeight, getGridColor, getIntercellSpacing, getModel, getPreferredScrollableViewportSize, getPrintable, getRowCount, getRowHeight, getRowHeight, getRowMargin, getRowSelectionAllowed, getRowSorter, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedColumn, getSelectedColumnCount, getSelectedColumns, getSelectedRow, getSelectedRowCount, getSelectedRows, getSelectionBackground, getSelectionForeground, getSelectionModel, getShowHorizontalLines, getShowVerticalLines, getSurrendersFocusOnKeystroke, getTableHeader, getToolTipText, getUI, getUIClassID, getUpdateSelectionOnSort, getValueAt, initializeLocalVars, isCellSelected, isColumnSelected, isEditing, isRowSelected, moveColumn, paramString, prepareRenderer, print, print, print, print, print, removeColumn, removeColumnSelectionInterval, removeEditor, removeNotify, removeRowSelectionInterval, resizeAndRepaint, rowAtPoint, selectAll, setAutoCreateColumnsFromModel, setAutoCreateRowSorter, setAutoResizeMode, setCellEditor, setCellSelectionEnabled, setColumnModel, setColumnSelectionAllowed, setColumnSelectionInterval, setDefaultRenderer, setDragEnabled, setDropMode, setEditingColumn, setEditingRow, setFillsViewportHeight, setGridColor, setIntercellSpacing, setPreferredScrollableViewportSize, setRowMargin, setRowSelectionAllowed, setRowSelectionInterval, setRowSorter, setSelectionBackground, setSelectionForeground, setSelectionMode, setSelectionModel, setShowGrid, setShowHorizontalLines, setShowVerticalLines, setSurrendersFocusOnKeystroke, setTableHeader, setUI, setUpdateSelectionOnSort, setValueAt, sizeColumnsToFit, sizeColumnsToFit, sorterChanged, tableChanged, unconfigureEnclosingScrollPane, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CLICK_ACTION

public static final String CLICK_ACTION
See Also:
Constant Field Values

ENTER_ACTION

public static final String ENTER_ACTION
See Also:
Constant Field Values

CELLTRAVERSAL_NONE

public static final int CELLTRAVERSAL_NONE
See Also:
Constant Field Values

CELLTRAVERSAL_COLUMN

public static final int CELLTRAVERSAL_COLUMN
See Also:
Constant Field Values

CELLTRAVERSAL_ROW

public static final int CELLTRAVERSAL_ROW
See Also:
Constant Field Values

CELLTRAVERSAL_NOLINEWRAP

public static final int CELLTRAVERSAL_NOLINEWRAP
See Also:
Constant Field Values

CELLTRAVERSAL_WRAPINLINE

public static final int CELLTRAVERSAL_WRAPINLINE
See Also:
Constant Field Values

CELLTRAVERSAL_NOTABLEWRAP

public static final int CELLTRAVERSAL_NOTABLEWRAP
See Also:
Constant Field Values

CELLTRAVERSAL_SKIPNOEDIT

public static final int CELLTRAVERSAL_SKIPNOEDIT
See Also:
Constant Field Values

CELLTRAVERSAL_AUTOEDIT

public static final int CELLTRAVERSAL_AUTOEDIT
See Also:
Constant Field Values
Constructor Detail

FormTable

public FormTable(TableModel model)
Creates a formtable for a given data model.

Parameters:
model - the data model

FormTable

public FormTable()
Creates an empty form table. The model has to set by setModel(javax.swing.table.TableModel).

Method Detail

setDefaultEditor

public void setDefaultEditor(Class<?> columnClass,
                             TableCellEditor editor)
Sets a default cell editor to be used if no editor has been set in a 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).

Overrides:
setDefaultEditor in class JTable
Parameters:
columnClass - set the default cell editor for this columnClass
editor - default cell editor to be used for this columnClass
See Also:
TableModel.isCellEditable(int, int), JTable.getDefaultEditor(java.lang.Class), JTable.setDefaultRenderer(java.lang.Class, javax.swing.table.TableCellRenderer)

getHelpURL

public String getHelpURL()
Gets the help url.

Returns:
the help url, null if none

setHelpURL

public void setHelpURL(String helpURL)
Sets the help url.

Parameters:
helpURL - the help url, null if none

isFormTraversable

public boolean isFormTraversable()
Returns whether the table may receive keyboard focus due to a form traversal.

Returns:
true if can receive focus, default is false (focus only by mouse-click)

setFormTraversable

public void setFormTraversable(boolean formTraversable)
Sets whether the table may receive keyboard focus due to a form traversal.

Parameters:
formTraversable - true if can receive focus, default is false (focus only by mouse-click)

isDataChanged

public boolean isDataChanged()
Determines whether some data cell has been changed.

Returns:
true if table data has been changed by user

getPreferencesName

public 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. E.g.: "/de/krake/bixworx/common/OpAusziffTableEntry/opAusziffOpTable"

Parameters:
entry - the formtable entry
Returns:
the Preferences name, null if table model does not support that feature

createDefaultColumnsFromPreferences

public boolean createDefaultColumnsFromPreferences(String prefName,
                                                   boolean systemOnly)
Creates the columns from the Preferences and sets the preferred table size according to the column sizes.

Parameters:
prefName - is the name of the Preferences-node
systemOnly - is true if take from SystemPreferences only. Otherwise system is only consulted if there is no user setting.
Returns:
true if columns or size changed, false if no preferences found at all

getPreferencesSize

public Dimension getPreferencesSize()
Gets the preferred size as defined by the preferences.

Returns:
the preferred size from the preferences

isCreateDefaultColumnsFromPreferences

public boolean isCreateDefaultColumnsFromPreferences()
Returns whether the columns are created according to the preferences.

Returns:
true if columns are created according to Preferences

setCreateDefaultColumnsFromPreferences

public void setCreateDefaultColumnsFromPreferences(boolean createDefaultColumnsFromPreferences)
Sets whether the columns are created according to the preferences.

Parameters:
createDefaultColumnsFromPreferences - true if createDefaultColumnsFromModel() should invoke createDefaultColumnsFromPreferences()

createDefaultColumnsFromModel

public void createDefaultColumnsFromModel()
Creates default columns for the table from the data model using the 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).

Overrides:
createDefaultColumnsFromModel in class JTable
See Also:
JTable.getAutoCreateColumnsFromModel()

createDefaultColumnsFromDefaultModel

public void createDefaultColumnsFromDefaultModel()
Creates the columns from the default column model


savePreferences

public void savePreferences(String prefName,
                            boolean system)
                     throws BackingStoreException
Saves the preferences of this table.

Parameters:
prefName - the name of the Preferences-node
system - true if store to system-preferences, else store in userprefs
Throws:
BackingStoreException - if save failed

setSelectedRow

public void setSelectedRow(int row)
Sets the row-selection (single row) (getSelectedRow is implemented in JTable but not setSelectedRow, for whatever reason)

Parameters:
row - the row number

setSelectedRows

public void setSelectedRows(int[] rows)
Sets the row-selection for an array of rows.

Parameters:
rows - the rows

setSelectedColumn

public void setSelectedColumn(int col)
Sets the selected column. (getSelectedColumn is implemented in JTable but not setSelectedColumn, for whatever reason)

Parameters:
col - the column number

setSelectedColumns

public void setSelectedColumns(int[] cols)
Sets the col-selection for an array of columns.

Parameters:
cols - the columns

getEntryAt

public FormTableEntry getEntryAt(int row)
Gets the FormTableEntry at a given (visible) row. Works only if the model is a FormTableModel.

Parameters:
row - the row number
Returns:
the formtable entry, null if no such entry

getObjectAt

public Object getObjectAt(int row)
Gets the data object that is associated to a given (visible) row. Works only if the model is a FormTableModel.

Parameters:
row - the row number
Returns:
the data object, null if no such row

getSelectedObject

public Object getSelectedObject()
Gets the data object at the current row. Useful for action listeners when row is double-clicked. Works only if the model is a FormTableModel.

Returns:
the dataobject, null if no current selection

queueEvent

protected void queueEvent(AWTEvent e)
Queues an Event at the end of the event-queue.

Parameters:
e - the event

processEvent

protected void processEvent(AWTEvent e)
Processes events on this container. If the event is a 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

Overrides:
processEvent in class Container
Parameters:
e - the event
See Also:
Component.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)

createDefaultColumnModel

protected TableColumnModel createDefaultColumnModel()
Returns the default column model object, which is a 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.

Overrides:
createDefaultColumnModel in class JTable
Returns:
the default column model object
See Also:
DefaultTableColumnModel

setColumnVisible

public void setColumnVisible(int columnIndex,
                             boolean visible)
Hides or displays a column.

Parameters:
columnIndex - the column index according to the data-model.
visible - true if column is made visible, false if invisible

isColumnVisible

public boolean isColumnVisible(int columnIndex)
Returns whether column is visible or not.

Parameters:
columnIndex - the column index according to the data-model.
Returns:
true if column is made visible, false if invisible

processKeyBinding

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. 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.

Overrides:
processKeyBinding in class JTable
Parameters:
ks - the KeyStroke queried
e - the KeyEvent
condition - one of the following values:
  • JComponent.WHEN_FOCUSED
  • JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
  • JComponent.WHEN_IN_FOCUSED_WINDOW
pressed - true if the key is pressed
Returns:
true if there was a binding to an action, and the action was enabled

setSelectedForeground

public void setSelectedForeground(Color c)
Sets the color for the selected foreground.

Parameters:
c - the foreground color

getSelectedForeground

public Color getSelectedForeground()
Gets the color for the selected foreground.

Returns:
the foreground color

setSelectedBackground

public void setSelectedBackground(Color c)
Sets the color for the selected background.

Parameters:
c - the background color

getSelectedBackground

public Color getSelectedBackground()
Gets the color for the selected background.

Returns:
the background color

setUnselectedForeground

public void setUnselectedForeground(Color c)
Sets the color for the unselected foreground.

Parameters:
c - the unselected foreground color

getUnselectedForeground

public Color getUnselectedForeground()
Gets the color for the unselected foreground.

Returns:
the unselected foreground color

setUnselectedBackground

public void setUnselectedBackground(Color c)
Sets the color for the unselected background.

Parameters:
c - the background color

getUnselectedBackground

public Color getUnselectedBackground()
Gets the color for the unselected background.

Returns:
the unselected background color

setFocusedForeground

public void setFocusedForeground(Color c)
Sets the color for the focus foreground.

Parameters:
c - the focus foreground color

getFocusedForeground

public Color getFocusedForeground()
Gets the color for the focus foreground.

Returns:
the focus foreground color

setFocusedBackground

public void setFocusedBackground(Color c)
Sets the color for the focus background.

Parameters:
c - the focus background color

getFocusedBackground

public Color getFocusedBackground()
Gets the color for the focus background.

Returns:
the focus background color

isEditing

public boolean isEditing(int row,
                         int column)
Returns whether the given cell is currently being edited.

Parameters:
row - the row index
column - the column index
Returns:
true is cell is being edited

editCellLater

public void editCellLater(int row,
                          int column)
Starts editing at a given row/column.
If the cell is already being edited (i.e. cause of keyboard type-ahead) the editing will *NOT* start over, i.e. does nothing. This is in order to avoid typed ahead keys with EnterKeyTraversal enabled.

Notice that the edit-request is queued!

Parameters:
row - the row index
column - the column index

editNextCellLater

public void editNextCellLater(int row,
                              int column)
Same as editCellLater but advance to next editable cell if given cell is not editable.

Notice that the edit-request is queued!

Parameters:
row - the row index
column - the column index
See Also:
editCellLater(int, int)

editPreviousCellLater

public void editPreviousCellLater(int row,
                                  int column)
Same as editCellLater but advance to previous editable cell if given cell is not editable

Notice that the edit-request is queued!

Parameters:
row - the row index
column - the column index
See Also:
editCellLater(int, int)

editNextCellLater

public void editNextCellLater()
Edits the next cell according to cellTraversal.

Notice that the edit-request is queued!


editPreviousCellLater

public void editPreviousCellLater()
Edits the previous cell according to cellTraversal.

Notice that the edit-request is queued!


editCellAt

public 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. 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.

Overrides:
editCellAt in class JTable
Parameters:
row - the row to be edited
column - the column to be edited
e - event to pass into shouldSelectCell; note that as of Java 2 platform v1.2, the call to shouldSelectCell is no longer made
Returns:
false if for any reason the cell cannot be edited, or if the indices are invalid

editingStopped

public void editingStopped(ChangeEvent e)
Invoked when editing is finished. The changes are saved and the editor is discarded.

Application code will not use these methods explicitly, they are used internally by JTable.

Overridden to catch the last key for generating CellTraversalEvents

Specified by:
editingStopped in interface CellEditorListener
Overrides:
editingStopped in class JTable
Parameters:
e - the event received
See Also:
CellEditorListener

editingCanceled

public void editingCanceled(ChangeEvent e)
Description copied from class: javax.swing.JTable
Invoked when editing is canceled. The editor object is discarded and the cell is rendered once again.

Application code will not use these methods explicitly, they are used internally by JTable.

Specified by:
editingCanceled in interface CellEditorListener
Overrides:
editingCanceled in class JTable
Parameters:
e - the event received
See Also:
CellEditorListener

inhibitCellTraversal

public void inhibitCellTraversal()
Inhibits cell traversal once.
Useful if we should stay in selected field even after Enter-key has been pressed. For ex. to disable wrapping to the next line if we are at end of line.


clearInhibitCellTraversal

public void clearInhibitCellTraversal()
Clears the inhibit of the cell traversal if for some reason set erroneously.


discardCellEvents

public void discardCellEvents()
Discards all cell events in the event queue.


setModel

public 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.

Overridden to setup the formatting, renderers and editors.

Overrides:
setModel in class JTable
Parameters:
dataModel - the new data source for this table
See Also:
JTable.getModel()

configureRenderers

public void configureRenderers()
Updates the renderers.
Useful, for example, if the some configuration changed and the renderers are fixed (see FormTableEntry.isCellRendererFixed()). Does nothing if the current model is not an AbstractFormTableModel.


configureEditors

public void configureEditors()
Updates the editors.
Useful, for example, if the some configuration changed and the editors are fixed (see FormTableEntry.isCellEditorFixed()). Does nothing if the current model is not an AbstractFormTableModel.


getColumnByModelIndex

public TableColumn getColumnByModelIndex(int modelIndex)
Gets the table-column according to the data-model index.

Parameters:
modelIndex - the column index according to the data model
Returns:
the table-column (even if it is not visible, see FormTableColumnModel)

getDefaultCellRect

public Rectangle getDefaultCellRect(int row,
                                    int column,
                                    boolean includeSpacing)
Refers to the default implementation of getCellRect() because overridden.

Parameters:
row - the row index
column - the column index
includeSpacing - false to return the true cell bounds
Returns:
the rectangle
See Also:
JTable.getCellRect(int, int, boolean)

getCellRect

public Rectangle getCellRect(int row,
                             int column,
                             boolean includeSpacing)
Returns a rectangle for the cell that lies at the intersection of 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.

Overrides:
getCellRect in class JTable
Parameters:
row - the row index where the desired cell is located
column - 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 index
includeSpacing - if false, return the true cell bounds - computed by subtracting the intercell spacing from the height and widths of the column and row models
Returns:
the rectangle containing the cell at location row,column
See Also:
JTable.getIntercellSpacing()

changeSelection

public 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. 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:

Overridden to implement cell merging.

Overrides:
changeSelection in class JTable
Parameters:
rowIndex - affects the selection at row
columnIndex - affects the selection at column
toggle - see description above
extend - if true, extend the current selection

setCellTraversal

public void setCellTraversal(int mode)
Sets the cell traversal mode.

Parameters:
mode - the cell traversal mode, one or more of CELLTRAVERSAL_...

getCellTraversal

public int getCellTraversal()
Sets the cell traversal mode.

Returns:
the cell traversal mode

addListSelectionListener

public void addListSelectionListener(ListSelectionListener listener)
Adds a selection changed listener.

Parameters:
listener - the listener to add

removeListSelectionListener

public void removeListSelectionListener(ListSelectionListener listener)
Removes a selection changed Listener.

Parameters:
listener - the listener to remove

fireValueChanged

public void fireValueChanged(ListSelectionEvent evt)
Notifies all Listeners that the selection has changed.

Parameters:
evt - the selection event

valueChanged

public void valueChanged(ListSelectionEvent evt)
Invoked when the row selection changes.

Overridden to fire the formtable listeners.

Specified by:
valueChanged in interface ListSelectionListener
Overrides:
valueChanged in class JTable
Parameters:
evt - the selection event
See Also:
ListSelectionListener

addFormTableTraversalListener

public void addFormTableTraversalListener(FormTableTraversalListener listener)
Adds a traversal listener.

Parameters:
listener - the listener to add

removeFormTableTraversalListener

public void removeFormTableTraversalListener(FormTableTraversalListener listener)
Removes a traversal listener

Parameters:
listener - the listener to remove

fireTraversalRequested

public void fireTraversalRequested(FormTableTraversalEvent evt)
                            throws FormTableTraversalVetoException
Notifies all traversal listeners that a cell traversal is triggered.

Parameters:
evt - the traversal event
Throws:
FormTableTraversalVetoException - if traversal vetoed

addActionListener

public void addActionListener(ActionListener listener)
Adds an action listener (usually a double click on a selection).

Parameters:
listener - the listener to add

removeActionListener

public void removeActionListener(ActionListener listener)
Removes an action Listener

Parameters:
listener - the listener to remove

fireActionPerformed

public void fireActionPerformed(ActionEvent evt)
Notifies all action listeners.

Parameters:
evt - the action event

getClickCount

public int getClickCount()
Gets the number of mouse clicks that caused the current selection.

Returns:
the number of mouse clicks

setClickCountToAction

public void setClickCountToAction(int clicks)
Sets the number of mouse clicks to trigger an action event.

Parameters:
clicks - the number of clicks, default is 2.

getClickCountToAction

public int getClickCountToAction()
Gets the number of mouse clicks to trigger an action event.

Returns:
the number of clicks, default is 2.

setEnterActionEnabled

public void setEnterActionEnabled(boolean enableEnterAction)
Enables/disables ENTER to trigger actionPerformed if row is selected.

Notice that enabling ENTER action is only meaningful if the table is not editable and celltraversal is turned off.

Parameters:
enableEnterAction - true to enable, default is false

isEnterActionEnabled

public boolean isEnterActionEnabled()
Returns whether ENTER triggers actionPerformed.

Returns:
true if enabled, default is false

setClickCountToStart

public void setClickCountToStart(int clicks)
Sets the number of clicks to start the full editing mode of a cell.

Parameters:
clicks - the number of clicks, default is 2

getClickCountToStart

public int getClickCountToStart()
Gets the number of clicks to start the full editing mode of a cell.

Returns:
the number of clicks, default is 2

setChangeable

public void setChangeable(boolean changeable)
Sets all cells of the table editable/not-editable. Not-editable means that the isCellEditable will always return false.

Parameters:
changeable - true if cells are editable
See Also:
isCellEditable(int, int)

isChangeable

public boolean isChangeable()
Returns whether the cells of this table are editable.

Returns:
true if cells are editable
See Also:
isCellEditable(int, int)

isCellEditable

public boolean isCellEditable(int row,
                              int column)
Returns true if the cell at 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.

Overrides:
isCellEditable in class JTable
Parameters:
row - the row whose value is to be queried
column - the column whose value is to be queried
Returns:
true if the cell is editable
See Also:
JTable.setValueAt(java.lang.Object, int, int)

setFormat

public void setFormat(int column,
                      String fmt)
Sets the format for a given column.

Parameters:
column - the column index
fmt -

setFormat

public void setFormat(String[] fmt)
Sets the format for all columns.

Parameters:
fmt - the format array (size must match the number of columns)

getFormat

public String getFormat(int column)
Gets the format of a column.

Parameters:
column - the column index
Returns:
the format string

getFormat

public String[] getFormat()
Gets the format strings of all columns.

Returns:
the format strings

setAutoSelect

public void setAutoSelect(int column,
                          boolean autoSelect)
Sets the autoselect flag. (only effective in editing-mode of the cell, usually a double-click)

Parameters:
column - the column index
autoSelect - true to enable autoselect, default is false

setAutoSelect

public void setAutoSelect(boolean autoSelect)
Sets autoSelect for all columns.

Parameters:
autoSelect - true to enable autoselect, default is false

isAutoSelect

public boolean isAutoSelect(int column)
Gets the autoselect flag.

Parameters:
column - the column index
Returns:
true if autoselect is enabled

setBlankZero

public void setBlankZero(int column,
                         boolean blankZero)
Sets the blankzero flag. (only applicable for Number-Fields)

Parameters:
column - the column index
blankZero - true to enable zero suppression, default is false

setBlankZero

public void setBlankZero(boolean blankZero)
Sets the blankzero flag for all columns. (only applicable for Number-Fields)

Parameters:
blankZero - true to enable zero suppression, default is false

isBlankZero

public boolean isBlankZero(int column)
Gets the blankzero flag.

Parameters:
column - the column index
Returns:
true if zero suppression is enabled

setConvert

public void setConvert(int column,
                       char convert)
Sets the convert flag.

Parameters:
column - the column index
convert - the character conversion mode, default is FormField.CONVERT_NONE

setConvert

public void setConvert(char convert)
Sets the convert flag for all columns.

Parameters:
convert - the character conversion mode, default is FormField.CONVERT_NONE

getConvert

public char getConvert(int column)
Gets the convert flag.

Parameters:
column - the column index
Returns:
the character conversion mode

setAdjust

public void setAdjust(int column,
                      char adjust)
Sets the adjust flag.

Parameters:
column - the column index
adjust - the adjustment mode, default is FormField.ADJUST_TRIM

setAdjust

public void setAdjust(char adjust)
Sets the adjust flag for all columns.

Parameters:
adjust - the adjustment mode, default is FormField.ADJUST_TRIM

getAdjust

public char getAdjust(int column)
Gets the adjust flag.

Parameters:
column - the column index
Returns:
the adjustment mode

setHorizontalAlignment

public void setHorizontalAlignment(int column,
                                   int align)
Sets the horizontal alignment (not to be mixed up with ADJUST_...)

Parameters:
column - the column index
align - the alignment
See Also:
JLabel.setHorizontalAlignment(int)

setHorizontalAlignment

public void setHorizontalAlignment(int align)
Sets the horizontal alignment for all columns.

Parameters:
align - the alignment
See Also:
JLabel.setHorizontalAlignment(int)

getHorizontalAlignment

public int getHorizontalAlignment(int column)
Gets the horizontal alignment.

Parameters:
column - the column index
Returns:
the alignment, -1 if not set
See Also:
JLabel.setHorizontalAlignment(int)

setVerticalAlignment

public void setVerticalAlignment(int column,
                                 int align)
Sets the vertical alignment.
Works only if a tentackle-plaf is used.

Parameters:
column - the column index
align - the alignment
See Also:
JLabel.setVerticalAlignment(int)

setVerticalAlignment

public void setVerticalAlignment(int align)
Sets the vertical alignment for all columns.
Works only if a tentackle-plaf is used.

Parameters:
align - the alignment
See Also:
JLabel.setVerticalAlignment(int)

getVerticalAlignment

public int getVerticalAlignment(int column)
Gets the vertical alignment.

Parameters:
column - the column index
Returns:
the alignment, -1 if not set
See Also:
JLabel.setHorizontalAlignment(int)

getDateFormat

public DateFormat getDateFormat(int column,
                                boolean asTimestamp)
Gets the date format.
If not set the default format is used from StringHelper.

Parameters:
column - the column index
asTimestamp - true if default format to use is for timestamps
Returns:
the date format
See Also:
StringHelper.shortDateFormat, StringHelper.shortTimestampFormat

getDateFormat

public DateFormat getDateFormat(int column)
Gets the date format.
If not set the default format is used from StringHelper.

Parameters:
column - the column index
Returns:
the date format
See Also:
StringHelper.shortDateFormat

getNumberFormat

public NumberFormat getNumberFormat(int column)
Gets the number format.

Parameters:
column - the column index
Returns:
the number format
See Also:
StringHelper.integerPattern

setMinRowHeight

public void setMinRowHeight(int minRowHeight)
Sets the minimum row-height.

Parameters:
minRowHeight - the minimum row height in pixels, 0 = no limit

getMinRowHeight

public int getMinRowHeight()
Gets the minimum row-height.

Returns:
the minimum row height in pixels, default is 0

setMaxRowHeight

public void setMaxRowHeight(int maxRowHeight)
Sets the maximum row-height.

Parameters:
maxRowHeight - the minimum row height in pixels, 0 = no limit

getMaxRowHeight

public int getMaxRowHeight()
Gets the maximum row-height.

Returns:
the maximum row height in pixels, default is 0 = no limit

setRowHeight

public void setRowHeight(int row,
                         int rowHeight)
Sets the height for 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

Overrides:
setRowHeight in class JTable
Parameters:
row - the row whose height is being changed
rowHeight - new row height, in pixels

setRowHeight

public void setRowHeight(int rowHeight)
Sets the height, in pixels, of all cells to 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

Overrides:
setRowHeight in class JTable
Parameters:
rowHeight - new row height
See Also:
JTable.getRowHeight()

scrollToCell

public void scrollToCell(int row,
                         int column)
Scrolls to the row, column so that it's visible.

Parameters:
row - the row index
column - the column index
See Also:
JComponent.scrollRectToVisible(java.awt.Rectangle)

isIgnoreSizeInPreferences

public boolean isIgnoreSizeInPreferences()
Returns whether sizes in the preferences are ignored.

Returns:
true if the sizes in the preferences are be ignored. Default is false.

setIgnoreSizeInPreferences

public void setIgnoreSizeInPreferences(boolean ignoreSizeInPreferences)
Returns whether sizes in the preferences are ignored.
In apps with fixed window sizes (i.e. isResizable() == false) createDefaultColumnsFromPreferences() can force an unwanted minimum window size because it will set the tablesize of the table from the preferences. This can be turned off.

Parameters:
ignoreSizeInPreferences - true if don't setPreferredSize, default is false.

isCellEditorFixed

public boolean isCellEditorFixed()
Returns whether all cell editors are fixed or may change dynamically.

Returns:
true if cell editors don't change dynamically (default)

setCellEditorFixed

public void setCellEditorFixed(boolean cellEditorFixed)
Sets whether all cell editors are fixed or may change dynamically.

Parameters:
cellEditorFixed - true if cell editors don't change dynamically (default)

isCellRendererFixed

public boolean isCellRendererFixed()
Returns whether all cell renderers are fixed or may change dynamically.

Returns:
true if cell renderers don't change dynamically (default)

setCellRendererFixed

public void setCellRendererFixed(boolean cellRendererFixed)
Sets whether all cell renderers are fixed or may change dynamically.

Parameters:
cellRendererFixed - true if cell renderers don't change dynamically (default)

isCellRectFixed

public boolean isCellRectFixed()
Returns whether the cell rectangles are fixed or change dynamically.

Returns:
true if cells don't change sizes dynamically (default)

setCellRectFixed

public void setCellRectFixed(boolean cellRectFixed)
Sets whether the cell rectangles are fixed or change dynamically.

Parameters:
cellRectFixed - true if cells don't change sizes dynamically (default)

getCellRenderer

public TableCellRenderer getCellRenderer(int row,
                                         int column)
Returns an appropriate renderer for the cell specified by this row and column. If the 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.

Overrides:
getCellRenderer in class JTable
Parameters:
row - the row of the cell to render, where 0 is the first row
column - the column of the cell to render, where 0 is the first column
Returns:
the assigned renderer; if null returns the default renderer for this type of object
See Also:
DefaultTableCellRenderer, TableColumn.setCellRenderer(javax.swing.table.TableCellRenderer), JTable.setDefaultRenderer(java.lang.Class, javax.swing.table.TableCellRenderer)

getCellEditor

public TableCellEditor getCellEditor(int row,
                                     int column)
Returns an appropriate editor for the cell specified by 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.

Overrides:
getCellEditor in class JTable
Parameters:
row - the row of the cell to edit, where 0 is the first row
column - the column of the cell to edit, where 0 is the first column
Returns:
the editor for this cell; if null return the default editor for this type of cell
See Also:
DefaultCellEditor

getDefaultEditor

public TableCellEditor getDefaultEditor(Class columnClass)
Returns the editor to be used when no editor has been set in a 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.

Overrides:
getDefaultEditor in class JTable
Parameters:
columnClass - return the default cell editor for this columnClass
Returns:
the default cell editor to be used for this columnClass
See Also:
JTable.setDefaultEditor(java.lang.Class, javax.swing.table.TableCellEditor), JTable.getColumnClass(int)

isCellDragEnabled

public boolean isCellDragEnabled()
Returns whether cell drag is enabled.

Returns:
true if enabled

setCellDragEnabled

public void setCellDragEnabled(boolean cellDragEnabled)
Enables or disables cell dragging.
The default TransferHandler in MetalLookAndFeel drags cells only if column-selection is allowed. In such a case (which is the 99%-case of standard apps) the whole row will be dragged. The FormTable, however, with the tentackle-plafs dragging will default to the anchor-cell of the selection. If you need row-dragging you must setCellDragEnabled(false).

Parameters:
cellDragEnabled - true to enable cell drag (default), false for row drag

prepareEditor

public 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.

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.

Overrides:
prepareEditor in class JTable
Parameters:
editor - the TableCellEditor to set up
row - the row of the cell to edit, where 0 is the first row
column - the column of the cell to edit, where 0 is the first column
Returns:
the Component being edited


Copyright © 2001-2008 Harald Krake, Bergstr. 48, 78098 Triberg, Germany, harald@krake.de