dyntable
Class JDynTable

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--dyntable.JDynTable
All Implemented Interfaces:
javax.accessibility.Accessible, EntityListListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.swing.event.TableColumnModelListener

public class JDynTable
extends javax.swing.JPanel
implements EntityListListener, javax.swing.event.TableColumnModelListener

$Id: Jdyntable.java,v 1.0 2005/09/25 jDynTable@gmx.de $
Jdyntable is a full-featured swing-based GUI component that represents a list of entities in a table with each row representing a different entity. This component can be used to provide users with the ability to edit specific properties of entities and/or to just manage the list of entities. Jdyntable conforms to the model/delegate framework and is driven by two different types of models. The EntityList is an interface for the container being used to manage the entity objects. The EntityTableColumnModel defines the column representation of the entity properties. Once these two classes have been provided, the table can be rendered.
The following is a brief feature list of the Jdyntable:
- Embedded scrollpane that will appear as required based on viewable area.
- Three modes of object focus: table, row, and cell.
- Lockable columns that will remain visible during left/right panning.
- Virtual column in left-most position optionally displaying row number.
- Virtual row in bottom-most row allowing users to quickly add new rows.
- Row sorting function is accessible to users by double clicking the header of the column to drive the sort.
+ Normal Sorting
+ Right Alignment Sorting (sorting after right-aligning all strings)
To see the difference between the sorting methods, here is an example:
given the values: a,b,c,a1,b1
sorting would produce: a,a1,b,b1,c
right alignment sorting would produce: a,b,c,a1,b1
- cell combine and split
- dynamic cell resizing

Version:
$Revision: 1.0 $
Author:
$Author: jdyntable@gmx.de $
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, 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
JDynTable()
          Constructs a new EntityTable.
JDynTable(EntityList eList, EntityTableColumnModel cModel)
          Constructs a new JDynTable with the given EntityList to manage the entities and the EntityTableColumnModel to define the columns of the table.
JDynTable(int iRows, int iColumns)
          Constructs a new JDynTable with the given number of columns and rows.
 
Method Summary
 void addHeightForResize(int height)
          Add height to table-component for enabling proper height resize
 void columnAdded(javax.swing.event.TableColumnModelEvent e)
          Updates the table after a column has been added.
 int columnAtPoint(java.awt.Point p)
          Returns the index of the column at the given Point.
 void columnMarginChanged(javax.swing.event.ChangeEvent e)
          Updates the table after a change to the column margins.
 void columnMoved(javax.swing.event.TableColumnModelEvent e)
          Updates the table after a column has been moved.
 void columnRemoved(javax.swing.event.TableColumnModelEvent e)
          Updates the table after removing a column.
 void columnSelectionChanged(javax.swing.event.ListSelectionEvent e)
          Updates the table after a change in the column selection.
 void combine(int[] rows, int[] columns)
          Combines two or more cells in the table
 java.awt.Color getBackground()
          Returns the background colour of table cells which are not highlighted/selected.
 EntityTableColumnModel getColumnModel()
          Returns the EntityTableColumnModel which defines the table columns.
 EntityTableFocusType getCurrentFocusMode()
          Returns the currently used focus mode.
 EntityTableFocusType getDefaultFocusMode()
          Returns the default focus mode, this is one of EntityTableFocusType.ROW_FOCUS, EntityTableFocusType.CELL_FOCUS, or EntityTableFocusType.TABLE_FOCUS.
 int getDisplayedEntityIndexAtPoint(java.awt.Point p)
          Returns the index of the entity at the given point.
 EntityList getDisplayEntityList()
          Returns the EntityList in which all the entities are ordered in their display order.
 javax.swing.ListSelectionModel getDisplaySelectionModel()
          Returns the selection model associated with the display EntityList.
 java.lang.Object getEntityAtPoint(java.awt.Point p)
          Returns the entity in the EntityList displayed at the given point.
 int getEntityIndexAtPoint(java.awt.Point p)
          Returns the index of the entity in the EntityList displayed at the point specified on the screen.
 EntityList getEntityList()
          Returns the EntityList containing all the entities of the table.
 RowHeaderModel getRowHeaderModel()
           
 int getRowHeight(int row)
          Returns the height of a table row, in pixels.
 javax.swing.JScrollPane getScrollPane()
          Returns the JScrollPane instance used by the table, can be used for setting custom scroll bar policy
 java.awt.Color getSelectionBackground()
          Returns the selection background colour displayed for selected cells.
 int getSelectionMode()
          Returns the selection method for the table.
 javax.swing.ListSelectionModel getSelectionModel()
          Returns the selection model used to handle selections associated with the EntityList.
 boolean isCellFocusAllowed()
          Returns true if focusing on a cell is allowed, false otherwise.
 boolean isEntityIndexDisplayed()
          Returns true if the entity index is displayed in the virtual column, false otherwise.
 boolean isOrderLockedToList()
          Returns true if the changes in displayed row order affect the order in the driving EntityList.
 boolean isReadOnly()
          Returns true if the table is readOnly, false otherwise.
 boolean isRowFocusAllowed()
          Returns true if focusing on an entire row is allowed, false otherwise.
 boolean isRowNumberDisplayed()
          Returns true if row numbers are displayed in the virtual column, false otherwise.
 boolean isRowSortingAllowed()
          Returns true if row sorting is allowed, false otherwise.
 boolean isTableFocusAllowed()
          Returns true if focusing on the entire table is allowed, false otherwise.
 boolean isVirtualColumnEnabled()
          Returns true if the virtual column is enabled, false otherwise.
 boolean isVirtualRowEnabled()
          Returns true if this table has the virtual row enabled, false otherwise.
 boolean isWidthAutoCalculated()
          Returns true if the width is auto calculated, false otherwise.
 void listChanged(EntityListEvent e)
          Fires a table change event.
 void refresh()
          Updates the JDynTable with any changes made to the column model.
 void revalidate()
          Updates the JDynTable with any changes made to the column model.
 int rowAtPoint(java.awt.Point p)
          Returns the index of the row at the given Point.
 void setBackground(java.awt.Color c)
          Sets the background colour of the table.
 void setBackground(java.awt.Color color, int row, int column)
          Changes the Color type for one cell in the table
 void setCellFocusAllowed(boolean a)
          Enables or disables focusing on a cell.
 void setCellNotEditable(int row, int col)
          Sets one certain cell ineditable
 void setColumnModel(EntityTableColumnModel cModel)
          Sets the EntityTableColumnModel that defines the table columns and the mapping between an entity and the table columns.
 void setCurrentFocusMode(EntityTableFocusType f)
          Sets the currently used focus mode.
 void setDefaultFocusMode(EntityTableFocusType f)
          Sets the default focus mode.
 void setDisplaySelectionModel(javax.swing.ListSelectionModel l)
          Sets the selection model used to select table data.
 void setEntityIndexDisplayed(boolean d)
          Enables or disables display of the entity indices in the virtual column.
 void setEntityList(EntityList eList)
          Sets the EntityList for this table, replacing the current EntityList.
 void setFont(java.awt.Font font, int row, int column)
          Changes the font type for one cell in the table
 void setForeground(java.awt.Color color, int row, int column)
          Changes the Color type for one cell in the table
 void setListToTableOrder()
          Sets the order of the entities in the EntityList to match the displayed order of the EntityTable.
 void setMaximumSize(java.awt.Dimension p)
          Sets the maximum size of the table.
 void setMinimumSize(java.awt.Dimension p)
          Sets the minimum size of the table.
 void setOrderLockedToList(boolean b)
          Enables or disables Order Locking.
 void setPreferredSize(java.awt.Dimension p)
          Sets the preferred size of the table.
 void setPreferredWidth(int width)
          Set the preferred table width.
 void setReadOnly(boolean r)
          Makes the table readOnly or enables editing of the table.
 void setRowFocusAllowed(boolean a)
          Enables or disables forcusing on an entire row.
 void setRowHeight(int row, int rowHeight)
          Sets the height, in pixels, of all cells to rowHeight, revalidates, and repaints.
 void setRowNumberDisplayed(boolean d)
          Enables or disables displaying of the row numbers in the virtual column.
 void setRowSortingAllowed(boolean b)
          Enables or disables row sorting.
 void setSelectionBackground(java.awt.Color c)
          Sets the background colour displayed for cells which are selected.
 void setSelectionMode(int mode)
          Sets the selection method for the table.
 void setSelectionModel(javax.swing.ListSelectionModel l)
          Sets the selection model which is used to handle selections in the table.
 void setTableFocusAllowed(boolean a)
          Enables or disables focusing on the entire table.
 void setTableToListOrder()
          Sets the display order of the table entities to be that of the driving EntityList.
 void setVirtualColumnEnabled(boolean v)
          Enables or disables the virtual column.
 void setVirtualRowEnabled(boolean v)
          Enables or disables the virtual row at the bottom of the table.
 void setWidthAutoCalculated(boolean b)
          Enables or disables auto calculation of the table width.
 void sortByColumns(java.util.Vector columns)
          Sorts the rows according to the columns specified.
 void updateVirtualRow(int row)
          Checks if the virtual row was edited by the user and adds the virtual row data to the table if necessary.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setNextFocusableComponent, setOpaque, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JDynTable

public JDynTable()
Constructs a new EntityTable.


JDynTable

public JDynTable(int iRows,
                 int iColumns)
Constructs a new JDynTable with the given number of columns and rows.

Parameters:
iRows - the number of rows
iColumns - the number of columns

JDynTable

public JDynTable(EntityList eList,
                 EntityTableColumnModel cModel)
Constructs a new JDynTable with the given EntityList to manage the entities and the EntityTableColumnModel to define the columns of the table.

Parameters:
eList - the EntityList managing all the entities in the table
cModel - the EntityTableColumnModel defining the table columns
Method Detail

getRowHeight

public int getRowHeight(int row)
Returns the height of a table row, in pixels.

Parameters:
row - the row whose height is to be found out
Returns:
the height in pixel of a table row

setCellNotEditable

public void setCellNotEditable(int row,
                               int col)
Sets one certain cell ineditable

Parameters:
row - the row of the ineditable cell
col - the column of the ineditable cell

setRowHeight

public void setRowHeight(int row,
                         int rowHeight)
Sets the height, in pixels, of all cells to rowHeight, revalidates, and repaints.

Parameters:
row - the row whose height is to be set
rowHeight - new row height

columnAtPoint

public int columnAtPoint(java.awt.Point p)
Returns the index of the column at the given Point. The index returned can be used with the EntityTableColumnModel to retrieve the actual column or adjust column properties. The virtual column is not counted. The Point x and y values start at 0 and represent a location on the screen in pixels.

Parameters:
p - Point on the table
Returns:
int the index of the column. The first column has index 0.

rowAtPoint

public int rowAtPoint(java.awt.Point p)
Returns the index of the row at the given Point. The index returned can be used with the EntityList to retrieve the actual row. The Point x and y values start at 0 and represent a location on the screen in pixels.

Parameters:
p - Point on the table
Returns:
int index of the row. The first row has index 0.

getDisplayedEntityIndexAtPoint

public int getDisplayedEntityIndexAtPoint(java.awt.Point p)
Returns the index of the entity at the given point. The index returned can be used with the displayed EntityList to retrieve the actual row. The point x and y values start at 0 and represent a location on the screen in pixels.

Parameters:
p - Point on the table
Returns:
int index of the row. The first row has index 0.

getEntityIndexAtPoint

public int getEntityIndexAtPoint(java.awt.Point p)
Returns the index of the entity in the EntityList displayed at the point specified on the screen. The first entity has index 0. Since an entity corresponds to a row of table data, this actually returns the row index. The point x and y values start at 0 and represent a location on the screen.

Parameters:
p - Point on the table
Returns:
int the index of the entity

getEntityAtPoint

public java.lang.Object getEntityAtPoint(java.awt.Point p)
Returns the entity in the EntityList displayed at the given point. The first entity has index 0. The point x and y values start at 0 and represent a location on the screen.

Parameters:
p - Point on the table
Returns:
Object the entity at the given location

getEntityList

public EntityList getEntityList()
Returns the EntityList containing all the entities of the table. The EntityList can be null and manages the entities that represent the table data.

Returns:
the EntityList containing the table data

setEntityList

public void setEntityList(EntityList eList)
Sets the EntityList for this table, replacing the current EntityList. This is a quick way to replace the entire table data.

Parameters:
eList - the EntityList which stores the entitites in this table

getColumnModel

public EntityTableColumnModel getColumnModel()
Returns the EntityTableColumnModel which defines the table columns.

Returns:
the EntityTableColumnModel describing columns and the mapping between an entity and the table columns

setColumnModel

public void setColumnModel(EntityTableColumnModel cModel)
Sets the EntityTableColumnModel that defines the table columns and the mapping between an entity and the table columns.

Parameters:
cModel - the EntityTableColumnModel describing the table columns

getScrollPane

public javax.swing.JScrollPane getScrollPane()
Returns the JScrollPane instance used by the table, can be used for setting custom scroll bar policy

Returns:
the JScrollPane

combine

public void combine(int[] rows,
                    int[] columns)
Combines two or more cells in the table

Parameters:
rows - array of the cells in a row that are to be combined
columns - array of the cells in a column that are to be combined

setFont

public void setFont(java.awt.Font font,
                    int row,
                    int column)
Changes the font type for one cell in the table

Parameters:
row - number of the cell (starting at 0)
column - number of the cells (starting at 0)

setForeground

public void setForeground(java.awt.Color color,
                          int row,
                          int column)
Changes the Color type for one cell in the table

Parameters:
row - number of the cell (starting at 0)
column - number of the cells (starting at 0)

setBackground

public void setBackground(java.awt.Color color,
                          int row,
                          int column)
Changes the Color type for one cell in the table

Parameters:
row - number of the cell (starting at 0)
column - number of the cells (starting at 0)

setPreferredWidth

public void setPreferredWidth(int width)
Set the preferred table width.

Parameters:
width - preferred table width in pixels

addHeightForResize

public void addHeightForResize(int height)
Add height to table-component for enabling proper height resize

Parameters:
height - table height to be added

setWidthAutoCalculated

public void setWidthAutoCalculated(boolean b)
Enables or disables auto calculation of the table width. If enabled, the table will resize itself so that all columns will be visible.

Parameters:
b - enabled if true, disabled otherwise

isWidthAutoCalculated

public boolean isWidthAutoCalculated()
Returns true if the width is auto calculated, false otherwise. If enabled, the table will resize itself so that all columns will be visible.

Returns:
true if enabled, false otherwise

isVirtualRowEnabled

public boolean isVirtualRowEnabled()
Returns true if this table has the virtual row enabled, false otherwise. See the class description for this JDynTable for more information.

Returns:
true if the virtual row is enabled, false otherwise

setVirtualRowEnabled

public void setVirtualRowEnabled(boolean v)
Enables or disables the virtual row at the bottom of the table. By bringing focus to, editing, then leaving any cell within the virtual row, the user implicitly adds another row to this EntityTable. The virtual entity is actually added to the table if the virtual row loses focus (after being edited) or if the user presses the Enter key when the cell-editor for the right-most editable column in the virtual entity has the focus. Disabling the virtual row will prevent users from adding new rows to the table by using the table user interface. Rows can still be added using method calls.

Parameters:
v - enables the virtual row if true, disables otherwise

isVirtualColumnEnabled

public boolean isVirtualColumnEnabled()
Returns true if the virtual column is enabled, false otherwise. The virtual column is an extra column that appears to the left of any normal columns and is always visible, even when the user scrolls the columns of the EntityTable. It can be used to select rows, if row selection is enabled and to display useful information about the row, such as the row number or the row index.

Returns:
returns true if the virtual column is enabled, false otherwise

setVirtualColumnEnabled

public void setVirtualColumnEnabled(boolean v)
Enables or disables the virtual column. The virtual column is an extra column that appears to the left of any normal columns and is always visible, even when the user scrolls the columns of the Entitytable. It can be used to select rows, if row selection is enabled and to display useful information about the row, such as the row number or the row index.

Parameters:
v - enabled if true, disabled otherwise

isRowNumberDisplayed

public boolean isRowNumberDisplayed()
Returns true if row numbers are displayed in the virtual column, false otherwise. This displays the number of the visible row in the virtual column. Row numbers start at one for the topmost row. Note: the virtual row will have an '*' to distinguish it from any other row, and thus will not have a row number.

Returns:
true if row numbers are displayed, false otherwise

setRowNumberDisplayed

public void setRowNumberDisplayed(boolean d)
Enables or disables displaying of the row numbers in the virtual column. This displays the number of the visible row in the virtual column. Row numbers start at one for the topmost row. Note: the virtual row will have an '*' to distinguish it from any other row, and thus will not have a row number.

Parameters:
d - enabled if true, disabled otherwise

isEntityIndexDisplayed

public boolean isEntityIndexDisplayed()
Returns true if the entity index is displayed in the virtual column, false otherwise. This displays a number for each row representing the order in which the rows were added to the table. Note: the virtual row will have an '*' to distinguish it from any other row, and thus will not have a number.

Returns:
true if entity index is displayed, false otherwise

setEntityIndexDisplayed

public void setEntityIndexDisplayed(boolean d)
Enables or disables display of the entity indices in the virtual column. This displays a number for each row representing the order in which the rows were added to the table. Note: the virtual row will have an '*' to distinguish it from any other row, and thus will not have a number.

Parameters:
d - enabled if true, disabled otherwise

isReadOnly

public boolean isReadOnly()
Returns true if the table is readOnly, false otherwise. If enabled it prevents editing of the table data, if disabled it allows editing.

Returns:
true if the table is read only, false otherwise

setReadOnly

public void setReadOnly(boolean r)
Makes the table readOnly or enables editing of the table. If enabled it prevents editing of the table data, if disabled it allows editing.

Parameters:
r - makes the table readOnly if true, editable otherwise

isOrderLockedToList

public boolean isOrderLockedToList()
Returns true if the changes in displayed row order affect the order in the driving EntityList. If enabled then the order of the table data matches the order of the table data in the EntityList. If enabled then rows can't be sorted by double clicking on column headers.

Returns:
true if the order is locked, false otherwise

setOrderLockedToList

public void setOrderLockedToList(boolean b)
Enables or disables Order Locking. If enabled then the order of the table data matches the order of the table data in the EntityList. If enabled then rows can't be sorted by double clicking on column headers.

Parameters:
b - order locked if true, not locked otherwise

isRowSortingAllowed

public boolean isRowSortingAllowed()
Returns true if row sorting is allowed, false otherwise. If enabled then rows can be sorted by double clicking on the column headers. By repeated double clicking, sorting is switched between ascending and descending order.

Returns:
true if row sorting is allowed, false otherwise

setRowSortingAllowed

public void setRowSortingAllowed(boolean b)
Enables or disables row sorting. If enabled then rows can be sorted by double clicking on the column headers. By repeated double clicking, sorting is switched between ascending and descending order.

Parameters:
b - enabled if true, disabled otherwise

sortByColumns

public void sortByColumns(java.util.Vector columns)
Sorts the rows according to the columns specified. The Vector holds column index Integers. The rows will be sorted according to all the columns specified.

Parameters:
columns - the Vector containing the indices of the columns to sort by

setListToTableOrder

public void setListToTableOrder()
Sets the order of the entities in the EntityList to match the displayed order of the EntityTable.


setTableToListOrder

public void setTableToListOrder()
Sets the display order of the table entities to be that of the driving EntityList.


getDefaultFocusMode

public EntityTableFocusType getDefaultFocusMode()
Returns the default focus mode, this is one of EntityTableFocusType.ROW_FOCUS, EntityTableFocusType.CELL_FOCUS, or EntityTableFocusType.TABLE_FOCUS. The default focus mode determines what method will be used when the user is navigating through the table.

Returns:
the EntityTableFocusType representing the default mode of focus

setDefaultFocusMode

public void setDefaultFocusMode(EntityTableFocusType f)
Sets the default focus mode. This can be one of EntityTableFocusType.ROW_FOCUS, EntityTableFocusType.CELL_FOCUS, or EntityTableFocusType.TABLE_FOCUS. The property should only be set to a focus mode if that focus mode is enabled. For example, setting the default focus mode to row, when the row focus mode has been disabled should be avoided. Setting the default focus mode to one which is not enabled is ignored. To enable or disable focus modes call the following methods: setRowFocusAllowed(boolean), setCellFocusAllowed(boolean), and setTableFocusAllowed(boolean).

Parameters:
f - the new focus mode

getSelectionMode

public int getSelectionMode()
Returns the selection method for the table. Valid selection methods are: - MULTIPLE_INTERVAL_SELECTION - This enables selection of multiple possibly disjoint elements, this works for rows only. If enabled, selection of cells will mimic the behaviour of SINGLE_INTERVAL_SELECTION - SINGLE_INTERVAL_SELECTION - This enables selection of multiple elements, but they must be beside each other in the table. This works for cells or rows - SINGLE_SELECTION - This only allows the selection of one element. Once again this could be a row, or cell. See ListSelectionModel for more details.

Returns:
the symbolic identifier indicationg which selection mode is currently being used

setSelectionMode

public void setSelectionMode(int mode)
Sets the selection method for the table. Valid selection methods are:
- MULTIPLE_INTERVAL_SELECTION - This enables selection of multiple possibly disjoint elements, this works for rows only. If enabled, selection of cells will mimic the behaviour of SINGLE_INTERVAL_SELECTION - SINGLE_INTERVAL_SELECTION - This enables selection of multiple elements, but they must be beside each other in the table. This works for cells or rows - SINGLE_SELECTION - This only allows the selection of one element. Once again this could be a row, or cell. See ListSelectionModel for more details.

Parameters:
mode - the new selection method

setSelectionBackground

public void setSelectionBackground(java.awt.Color c)
Sets the background colour displayed for cells which are selected.

Parameters:
c - the new colour of the selection background

getSelectionBackground

public java.awt.Color getSelectionBackground()
Returns the selection background colour displayed for selected cells.

Returns:
the selection background colour

setBackground

public void setBackground(java.awt.Color c)
Sets the background colour of the table. This is the colour displayed for the background of every cell that is not highlighted/selected.

Overrides:
setBackground in class javax.swing.JComponent
Parameters:
c - the new colour to set the background to

getBackground

public java.awt.Color getBackground()
Returns the background colour of table cells which are not highlighted/selected.

Overrides:
getBackground in class java.awt.Component
Returns:
the background colour

getCurrentFocusMode

public EntityTableFocusType getCurrentFocusMode()
Returns the currently used focus mode. Only one method of focus is allowed at any one time. This returns the one being used currently. This is the method by which a user can select/highlight cells. See getSelectionMode function for information about selection. Valid values are EntityTableFocusType.ROW_FOCUS, EntityTableFocusType.CELL_FOCUS, or EntityTableFocusType.TABLE_FOCUS.

Returns:
the focus mode

setCurrentFocusMode

public void setCurrentFocusMode(EntityTableFocusType f)
Sets the currently used focus mode. Only one method of focus is allowed at any one time. This sets the one being used currently. This is the method by which a user can select/highlight cells. See getSelectionMode function for information about selection. Valid values are EntityTableFocusType.ROW_FOCUS, EntityTableFocusType.CELL_FOCUS, or EntityTableFocusType.TABLE_FOCUS.

Parameters:
f - the new focus mode

isTableFocusAllowed

public boolean isTableFocusAllowed()
Returns true if focusing on the entire table is allowed, false otherwise. See setCurrentFocusMode for more details.

Returns:
true if table focus is allowed, false otherwise

setTableFocusAllowed

public void setTableFocusAllowed(boolean a)
Enables or disables focusing on the entire table. See setCurrentFocusMode for more details.

Parameters:
a - enabled if true, disabled otherwise

isRowFocusAllowed

public boolean isRowFocusAllowed()
Returns true if focusing on an entire row is allowed, false otherwise. See setCurrentFocusMode for more details.

Returns:
true if row focus is allowed, false otherwise

setRowFocusAllowed

public void setRowFocusAllowed(boolean a)
Enables or disables forcusing on an entire row. See setCurrentFocusMode for more details.

Parameters:
a - enabled if true, disabled otherwise

isCellFocusAllowed

public boolean isCellFocusAllowed()
Returns true if focusing on a cell is allowed, false otherwise. See setCurrentFocusMode for more details.

Returns:
true if cell focus is allowed, false otherwise

setCellFocusAllowed

public void setCellFocusAllowed(boolean a)
Enables or disables focusing on a cell. See setCurrentFocusMode method for more details.

Parameters:
a - enabled if true, disabled otherwise

getDisplayEntityList

public EntityList getDisplayEntityList()
Returns the EntityList in which all the entities are ordered in their display order. See the class description of EntityList for more information.

Returns:
the entity list

getDisplaySelectionModel

public javax.swing.ListSelectionModel getDisplaySelectionModel()
Returns the selection model associated with the display EntityList. The ListSelectionModel is the model which controls selection in the table. Some valid selection modes are: - MULTIPLE_INTERVAL_SELECTION - This enables selection of multiple possibly disjoint elements, this works for rows only. If enabled, selection of cells will mimic the behaviour of SINGLE_INTERVAL_SELECTION - SINGLE_INTERVAL_SELECTION - This enables selection of multiple elements, but they must be beside each other in the table. This works for cells or rows - SINGLE_SELECTION - This only allows the selection of one element. Once again this could be a row, or cell. - See ListSelectionModel for more information.

Returns:
the ListSelectionModel used to select information in the table

setDisplaySelectionModel

public void setDisplaySelectionModel(javax.swing.ListSelectionModel l)
Sets the selection model used to select table data. The ListSelectionModel is the model which controls selection in the table. Some valid selection modes are:
- MULTIPLE_INTERVAL_SELECTION - This enables selection of multiple possibly disjoint elements, this works for rows only. If enabled, selection of cells will mimic the behaviour of SINGLE_INTERVAL_SELECTION - SINGLE_INTERVAL_SELECTION - This enables selection of multiple elements, but they must be beside each other in the table. This works for cells or rows - SINGLE_SELECTION - This only allows the selection of one element. Once again this could be a row, or cell. See ListSelectionModel for more information.

Parameters:
l - the new ListSelectionModel

getSelectionModel

public javax.swing.ListSelectionModel getSelectionModel()
Returns the selection model used to handle selections associated with the EntityList.

Returns:
the ListSelectionModel which handles selection

setSelectionModel

public void setSelectionModel(javax.swing.ListSelectionModel l)
Sets the selection model which is used to handle selections in the table.

Parameters:
l - the new ListSelectionModel which handles selection in the table

refresh

public void refresh()
Updates the JDynTable with any changes made to the column model. This method must be called after certain operations such as showing and hiding columns, and locking or unlocking columns. The revalidate and refresh methods perform the same function.


revalidate

public void revalidate()
Updates the JDynTable with any changes made to the column model. This method must be called after certain operations such as showing and hiding columns, and locking or unlocking columns. The revalidate and refresh methods perform the same function.

Overrides:
revalidate in class javax.swing.JComponent

setMinimumSize

public void setMinimumSize(java.awt.Dimension p)
Sets the minimum size of the table. This is the smallest size the table is allowed to be. The dimension is given as a width and height.

Overrides:
setMinimumSize in class javax.swing.JComponent
Parameters:
p - the Dimension which represents the new size

setMaximumSize

public void setMaximumSize(java.awt.Dimension p)
Sets the maximum size of the table. This is the largest size the table is allowed to be. The dimension is given as a width and height.

Overrides:
setMaximumSize in class javax.swing.JComponent
Parameters:
p - the Dimension which represents the new size

setPreferredSize

public void setPreferredSize(java.awt.Dimension p)
Sets the preferred size of the table. This is the size the table will try to be. The dimension is given as a width and height.

Overrides:
setPreferredSize in class javax.swing.JComponent
Parameters:
p - the new size

listChanged

public void listChanged(EntityListEvent e)
Fires a table change event. This method is called when the table data has changed.

Specified by:
listChanged in interface EntityListListener
Parameters:
e - the EntityListEvent providing information about the event

columnAdded

public void columnAdded(javax.swing.event.TableColumnModelEvent e)
Updates the table after a column has been added. This method is called whenever a new column is added to the table.

Specified by:
columnAdded in interface javax.swing.event.TableColumnModelListener
Parameters:
e - the TableColumnModelEvent that contains the details about the event

columnMarginChanged

public void columnMarginChanged(javax.swing.event.ChangeEvent e)
Updates the table after a change to the column margins. This method must be called whenever the column width changes so that that Table can update it's column sizes and resize appropriately. If this method is not called then when the user changes the column size by moving the mouse onto the dividing line between column titles and attempts to resize the column, the column will not resize.

Specified by:
columnMarginChanged in interface javax.swing.event.TableColumnModelListener
Parameters:
e - the ChangeEvent that contains the details about the event

columnMoved

public void columnMoved(javax.swing.event.TableColumnModelEvent e)
Updates the table after a column has been moved.

Specified by:
columnMoved in interface javax.swing.event.TableColumnModelListener
Parameters:
e - the TableColumnModelEvent that contains the details about the event

columnRemoved

public void columnRemoved(javax.swing.event.TableColumnModelEvent e)
Updates the table after removing a column.

Specified by:
columnRemoved in interface javax.swing.event.TableColumnModelListener
Parameters:
e - the TableColumnModelEvent that contains the details about the event

columnSelectionChanged

public void columnSelectionChanged(javax.swing.event.ListSelectionEvent e)
Updates the table after a change in the column selection.

Specified by:
columnSelectionChanged in interface javax.swing.event.TableColumnModelListener
Parameters:
e - the ListSelectionEvent that contains the details about the event

updateVirtualRow

public void updateVirtualRow(int row)
Checks if the virtual row was edited by the user and adds the virtual row data to the table if necessary.

Parameters:
row - the index of the row

getRowHeaderModel

public RowHeaderModel getRowHeaderModel()
Returns:
Returns the rowHeaderModel.