|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--javax.swing.JComponent | +--javax.swing.JPanel | +--dyntable.JDynTable
$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
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 |
public JDynTable()
public JDynTable(int iRows, int iColumns)
iRows
- the number of rowsiColumns
- the number of columnspublic JDynTable(EntityList eList, EntityTableColumnModel cModel)
eList
- the EntityList managing all the entities in the tablecModel
- the EntityTableColumnModel defining the table columnsMethod Detail |
public int getRowHeight(int row)
row
- the row whose height is to be found out
public void setCellNotEditable(int row, int col)
row
- the row of the ineditable cellcol
- the column of the ineditable cellpublic void setRowHeight(int row, int rowHeight)
row
- the row whose height is to be setrowHeight
- new row heightpublic int columnAtPoint(java.awt.Point p)
p
- Point on the table
public int rowAtPoint(java.awt.Point p)
p
- Point on the table
public int getDisplayedEntityIndexAtPoint(java.awt.Point p)
p
- Point on the table
public int getEntityIndexAtPoint(java.awt.Point p)
p
- Point on the table
public java.lang.Object getEntityAtPoint(java.awt.Point p)
p
- Point on the table
public EntityList getEntityList()
public void setEntityList(EntityList eList)
eList
- the EntityList which stores the entitites in this tablepublic EntityTableColumnModel getColumnModel()
public void setColumnModel(EntityTableColumnModel cModel)
cModel
- the EntityTableColumnModel describing the table columnspublic javax.swing.JScrollPane getScrollPane()
public void combine(int[] rows, int[] columns)
rows
- array of the cells in a row that are to be combinedcolumns
- array of the cells in a column that are to be combinedpublic void setFont(java.awt.Font font, int row, int column)
row
- number of the cell (starting at 0)column
- number of the cells (starting at 0)public void setForeground(java.awt.Color color, int row, int column)
row
- number of the cell (starting at 0)column
- number of the cells (starting at 0)public void setBackground(java.awt.Color color, int row, int column)
row
- number of the cell (starting at 0)column
- number of the cells (starting at 0)public void setPreferredWidth(int width)
width
- preferred table width in pixelspublic void addHeightForResize(int height)
height
- table height to be addedpublic void setWidthAutoCalculated(boolean b)
b
- enabled if true, disabled otherwisepublic boolean isWidthAutoCalculated()
public boolean isVirtualRowEnabled()
public void setVirtualRowEnabled(boolean v)
v
- enables the virtual row if true, disables otherwisepublic boolean isVirtualColumnEnabled()
public void setVirtualColumnEnabled(boolean v)
v
- enabled if true, disabled otherwisepublic boolean isRowNumberDisplayed()
public void setRowNumberDisplayed(boolean d)
d
- enabled if true, disabled otherwisepublic boolean isEntityIndexDisplayed()
public void setEntityIndexDisplayed(boolean d)
d
- enabled if true, disabled otherwisepublic boolean isReadOnly()
public void setReadOnly(boolean r)
r
- makes the table readOnly if true, editable otherwisepublic boolean isOrderLockedToList()
public void setOrderLockedToList(boolean b)
b
- order locked if true, not locked otherwisepublic boolean isRowSortingAllowed()
public void setRowSortingAllowed(boolean b)
b
- enabled if true, disabled otherwisepublic void sortByColumns(java.util.Vector columns)
columns
- the Vector containing the indices of the columns to sort bypublic void setListToTableOrder()
public void setTableToListOrder()
public EntityTableFocusType getDefaultFocusMode()
public void setDefaultFocusMode(EntityTableFocusType f)
f
- the new focus modepublic int getSelectionMode()
public void setSelectionMode(int mode)
ListSelectionModel
for more details.
mode
- the new selection methodpublic void setSelectionBackground(java.awt.Color c)
c
- the new colour of the selection backgroundpublic java.awt.Color getSelectionBackground()
public void setBackground(java.awt.Color c)
setBackground
in class javax.swing.JComponent
c
- the new colour to set the background topublic java.awt.Color getBackground()
getBackground
in class java.awt.Component
public EntityTableFocusType getCurrentFocusMode()
public void setCurrentFocusMode(EntityTableFocusType f)
f
- the new focus modepublic boolean isTableFocusAllowed()
public void setTableFocusAllowed(boolean a)
a
- enabled if true, disabled otherwisepublic boolean isRowFocusAllowed()
public void setRowFocusAllowed(boolean a)
a
- enabled if true, disabled otherwisepublic boolean isCellFocusAllowed()
public void setCellFocusAllowed(boolean a)
a
- enabled if true, disabled otherwisepublic EntityList getDisplayEntityList()
EntityList
in which all the entities are ordered
in their display order.
See the class description of EntityList for more information.
public javax.swing.ListSelectionModel getDisplaySelectionModel()
public void setDisplaySelectionModel(javax.swing.ListSelectionModel l)
ListSelectionModel
for more information.
l
- the new ListSelectionModel
public javax.swing.ListSelectionModel getSelectionModel()
public void setSelectionModel(javax.swing.ListSelectionModel l)
l
- the new ListSelectionModel which handles selection in the tablepublic void refresh()
public void revalidate()
revalidate
in class javax.swing.JComponent
public void setMinimumSize(java.awt.Dimension p)
setMinimumSize
in class javax.swing.JComponent
p
- the Dimension which represents the new sizepublic void setMaximumSize(java.awt.Dimension p)
setMaximumSize
in class javax.swing.JComponent
p
- the Dimension which represents the new sizepublic void setPreferredSize(java.awt.Dimension p)
setPreferredSize
in class javax.swing.JComponent
p
- the new sizepublic void listChanged(EntityListEvent e)
listChanged
in interface EntityListListener
e
- the EntityListEvent providing information about the eventpublic void columnAdded(javax.swing.event.TableColumnModelEvent e)
columnAdded
in interface javax.swing.event.TableColumnModelListener
e
- the TableColumnModelEvent that contains the details
about the eventpublic void columnMarginChanged(javax.swing.event.ChangeEvent e)
columnMarginChanged
in interface javax.swing.event.TableColumnModelListener
e
- the ChangeEvent that contains the details
about the eventpublic void columnMoved(javax.swing.event.TableColumnModelEvent e)
columnMoved
in interface javax.swing.event.TableColumnModelListener
e
- the TableColumnModelEvent that contains the details
about the eventpublic void columnRemoved(javax.swing.event.TableColumnModelEvent e)
columnRemoved
in interface javax.swing.event.TableColumnModelListener
e
- the TableColumnModelEvent that contains the details
about the eventpublic void columnSelectionChanged(javax.swing.event.ListSelectionEvent e)
columnSelectionChanged
in interface javax.swing.event.TableColumnModelListener
e
- the ListSelectionEvent that contains the details
about the eventpublic void updateVirtualRow(int row)
row
- the index of the rowpublic RowHeaderModel getRowHeaderModel()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |