Diamond Control Suite 3.0

diamondedge.swing.grid
Class DsTable

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 diamondedge.swing.grid.DsTable
All Implemented Interfaces:
DsConstants, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, CellEditorListener, ListSelectionListener, RowSorterListener, TableColumnModelListener, TableModelListener, Scrollable, SwingConstants
Direct Known Subclasses:
DsGrid, GridRowHeader

public class DsTable
extends JTable
implements DsConstants

A class which implements many common functions used in DsGrid and other tables

See Also:
Serialized Form

Nested Class Summary
static class DsTable.BooleanEditor
           
static class DsTable.BooleanRenderer
           
static class DsTable.ComponentEditor
           
static class DsTable.ComponentRenderer
           
static class DsTable.DateEditor
           
static class DsTable.ListEditor
           
static class DsTable.TableEditor
           
 
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
protected  boolean cellsEditable
           
protected  boolean spannedCells
           
 
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 diamondedge.swing.DsConstants
ACCOUNTING, ALL, ASCENDING, ASCENDING_CASE, BORDER_BOTTOM, BORDER_LEFT, BORDER_NONE, BORDER_OUTLINE, BORDER_RIGHT, BORDER_TOP, CROSS_LINES, DASH, DASH_DOT, DASH_DOT_DOT, DEFAULT, DESCENDING, DESCENDING_CASE, DIAGONAL_CROSS_LINES, DOT, DOUBLE, DOUBLE_LINE, DOWNWARD_DIAGONAL_LINES, ETCHED, ETCHED_RAISED, FALSE, FIND_ALL, FIND_EQUALS, FIND_GT, FIND_GTE, FIND_LT, FIND_LTE, FIND_NE, FIND_PREFIX, FIND_REGEX, FIND_STRING, FIRST, FLAT, GRID_DASH, GRID_DASH_DOT, GRID_DASH_DOT_DOT, GRID_DOT, GRID_LINE, HIGHLIGHT_SELECTION_ALWAYS, HIGHLIGHT_SELECTION_NEVER, HIGHLIGHT_SELECTION_WITH_FOCUS, HORIZONTAL_LINES, LOWERED, LOWERED_LIGHT, NONE, RAISED, RAISED_LIGHT, SELECT_CELL, SELECT_NONE, SELECT_ROW, SINGLE, SINGLE_LINE, SOLID, STRETCH, TILE, TRANSPARENT, TRUE, UPWARD_DIAGONAL_LINES, VERTICAL_LINES
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Method Summary
 TableColumn addColumn()
          Adds a column to the end.
 TableColumn addColumn(String columnName, String id)
          Adds a column to the end with the given name (HeaderValue) and identifier.
 void addColumn(TableColumn aColumn)
          Appends aColumn to the end of the array of columns held by the column model.
 int calculateColumnWidthToFit(int column, boolean fitName, boolean fitData)
          Returns the width of the column at the given index needed to fit the text for the name of the column and/or the data in cells in that column.
 int calculateWidthToFit(boolean fitColumnNames, boolean fitColumnData)
          Returns the total width of the table needed to fit the text for the name of the column and/or the data in cells in that column for each column in the table.
 int columnAtPoint(Point point)
           
 void columnSelectionChanged(ListSelectionEvent e)
           
protected  DsCell createCell()
          Returns a new DsCell.
 void createDefaultColumnsFromModel()
           
protected  void createDefaultEditors()
           
protected  void createDefaultRenderers()
           
protected  JTableHeader createDefaultTableHeader()
           
 DsCell getCellAt(int row, int col)
          Returns the cell at the given row and column.
protected  int getCellColumnSpan(int row, int column)
           
 TableCellEditor getCellEditor(int row, int column)
           
 Rectangle getCellRect(int row, int column, boolean includeSpacing)
           
 TableCellRenderer getCellRenderer(int row, int column)
           
protected  int getCellRowSpan(int row, int column)
           
 DsCellRange getCells(int firstRow, int firstColumn, int lastRow, int lastColumn)
          Returns a range of cells in between and including the specified cell corners.
 Object getCellValueAt(int row, int col)
          Returns the contents/object for the cell at the given row and column.
 TableColumn getColumn(int index)
          Returns the TableColumn object for the column at the given position.
 TableColumn getColumn(String columnId)
           
 int getColumnCount()
          Returns the total number of columns.
 DsTableColumnHeader getColumnHeader()
          Returns the column header.
 Color getColumnHeaderBackground()
          Returns the background color of the column header.
 Font getColumnHeaderFont()
          Returns the Font for the column headers
 Color getColumnHeaderForeground()
          Returns the color used to draw text of the column header.
 int getColumnHeaderHeight()
          Returns the height of the column header.
 int getColumnIndex(String columnId)
          Returns the column index for the column that has the given identifier or column name.
 String getColumnName(int column)
          Returns the object used to get the text displayed in the given column header.
 DsCellProperties getColumnProperties(int col)
          Returns the default cell containing the default properties for the column.
 DsCellRange getColumns(int firstColumn, int lastColumn)
          Returns a range of cells that includes all cells in the specified columns.
 int getColumnWidth(int index)
          Determines the width of the specified column in pixels.
 DsCellRange getRows(int firstRow, int lastRow)
          Returns a range of cells that includes all cells in the specified rows.
protected static JScrollPane getScrollPane(JTable table)
           
 String getToolTipText(MouseEvent event)
          Overrides JComponent's getToolTipText method in order to allow the cell's tips to be used if it has text set.
 void hideColumn(int index)
          Removes from the view the column at the given position.
 boolean isCellEditable(int row, int column)
          Returns true if the cell at row and column is editable.
 boolean isColumnReorderingAllowed()
          Returns true if the user is allowed to rearrange columns by dragging their headers, false otherwise.
 boolean isColumnResizingAllowed()
          Returns true if the user is allowed to resize columns by dragging between their headers, false otherwise.
 boolean isEditable()
          Returns whether any cell can be edited by the user.
 void removeSpan(int row, int column)
          Makes the cell at position row, column not span across multiple rows and/or columns.
 int rowAtPoint(Point point)
           
 void setColumnCount(int val)
          Sets the total number of columns by adding new columns or removing existing ones.
 void setColumnHeaderBackground(Color val)
          Sets the background color of the column header.
 void setColumnHeaderFont(Font f)
          Sets the Font for the column headers
 void setColumnHeaderForeground(Color val)
          Sets the color used to draw text of the column header.
 void setColumnHeaderHeight(int height)
          Sets the height of the column header.
 void setColumnHorizontalAlignment(int column, int align)
          Sets the horizontal alignment of the text in the column header.
 void setColumnName(int column, String val)
          Sets the text displayed in the column header.
 void setColumnReorderingAllowed(boolean reorderingAllowed)
          Shortcut to set whether the user can drag column headers to reorder columns.
 void setColumnResizingAllowed(boolean resizingAllowed)
          Shortcut to set whether the user can resize columns by dragging between headers.
 void setColumnVerticalAlignment(int column, int align)
          Sets the vertical alignment of the text in the column header.
 void setColumnWidth(int index, int width)
          Sets the width of the column at the given index to width.
 void setColumnWidth(String columnId, int width)
           
 void setColumnWidthToFit(int column, boolean fitName, boolean fitData)
          Sets the width of the column at the given index to fit the text for the name of the column and/or the data in cells in that column.
 void setEditable(boolean cellsCanBeEdited)
          Set whether any cell can be edited by the user.
 boolean spanCells(int startRow, int startColumn, int rowsToSpan, int columnsToSpan)
          Makes the cell at position startRow, startColumn span across rowsToSpan rows and columnsToSpan columns.
 void tableChanged(TableModelEvent e)
          Invoked when this table's TableModel generates a TableModelEvent.
 void updateUI()
           
 void valueChanged(ListSelectionEvent e)
           
 
Methods inherited from class javax.swing.JTable
addColumnSelectionInterval, addNotify, addRowSelectionInterval, changeSelection, clearSelection, columnAdded, columnMarginChanged, columnMoved, columnRemoved, configureEnclosingScrollPane, convertColumnIndexToModel, convertColumnIndexToView, convertRowIndexToModel, convertRowIndexToView, createDefaultColumnModel, createDefaultDataModel, createDefaultSelectionModel, createScrollPaneForTable, doLayout, editCellAt, editCellAt, editingCanceled, editingStopped, getAccessibleContext, getAutoCreateColumnsFromModel, getAutoCreateRowSorter, getAutoResizeMode, getCellEditor, getCellSelectionEnabled, getColumn, getColumnClass, getColumnModel, getColumnSelectionAllowed, getDefaultEditor, 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, getUI, getUIClassID, getUpdateSelectionOnSort, getValueAt, initializeLocalVars, isCellSelected, isColumnSelected, isEditing, isRowSelected, moveColumn, paramString, prepareEditor, prepareRenderer, print, print, print, print, print, processKeyBinding, removeColumn, removeColumnSelectionInterval, removeEditor, removeNotify, removeRowSelectionInterval, resizeAndRepaint, selectAll, setAutoCreateColumnsFromModel, setAutoCreateRowSorter, setAutoResizeMode, setCellEditor, setCellSelectionEnabled, setColumnModel, setColumnSelectionAllowed, setColumnSelectionInterval, setDefaultEditor, setDefaultRenderer, setDragEnabled, setDropMode, setEditingColumn, setEditingRow, setFillsViewportHeight, setGridColor, setIntercellSpacing, setModel, setPreferredScrollableViewportSize, setRowHeight, setRowHeight, setRowMargin, setRowSelectionAllowed, setRowSelectionInterval, setRowSorter, setSelectionBackground, setSelectionForeground, setSelectionMode, setSelectionModel, setShowGrid, setShowHorizontalLines, setShowVerticalLines, setSurrendersFocusOnKeystroke, setTableHeader, setUI, setUpdateSelectionOnSort, setValueAt, sizeColumnsToFit, sizeColumnsToFit, sorterChanged, unconfigureEnclosingScrollPane
 
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, processEvent, 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

cellsEditable

protected boolean cellsEditable

spannedCells

protected boolean spannedCells
Method Detail

updateUI

public void updateUI()
Overrides:
updateUI in class JTable

getScrollPane

protected static JScrollPane getScrollPane(JTable table)

isEditable

public final boolean isEditable()
Returns whether any cell can be edited by the user. If true then the TableModel will determine whether an individual cell can be edited.


setEditable

public void setEditable(boolean cellsCanBeEdited)
Set whether any cell can be edited by the user. If true then the TableModel isCellEditable will determine whether an individual cell can be edited. If false then no cells can be edited by the user. By default, the TableModel isCellEditable returns true for all cells, so by default this property will turn on/off the editing of all cells.


isCellEditable

public boolean isCellEditable(int row,
                              int column)
Returns true if the cell at row and column is editable. If the editable property on this table is set to false then no cell can be edited. If the editable property on a row, column, or cell is set then it is used, otherwise the TableModel will determine whether an individual cell can be edited.

Overrides:
isCellEditable in class JTable
See Also:
setEditable(boolean)

getCellAt

public DsCell getCellAt(int row,
                        int col)
Returns the cell at the given row and column. If the cell is currently null a new DsCell is added and returned.

See Also:
createCell()

createCell

protected DsCell createCell()
Returns a new DsCell.


getCellValueAt

public Object getCellValueAt(int row,
                             int col)
Returns the contents/object for the cell at the given row and column.


getCells

public DsCellRange getCells(int firstRow,
                            int firstColumn,
                            int lastRow,
                            int lastColumn)
Returns a range of cells in between and including the specified cell corners.

Parameters:
firstRow - the first row in the range of cells
firstColumn - the first column in the range of cells
lastRow - the last row in the range of cells
lastColumn - the last column in the range of cells

getRows

public DsCellRange getRows(int firstRow,
                           int lastRow)
Returns a range of cells that includes all cells in the specified rows.

Parameters:
firstRow - the first row in the range of cells
lastRow - the last row in the range of cells (inclusive)

getColumns

public DsCellRange getColumns(int firstColumn,
                              int lastColumn)
Returns a range of cells that includes all cells in the specified columns.

Parameters:
firstColumn - the first column in the range of cells
lastColumn - the last column in the range of cells (inclusive)

getColumnHeader

public final DsTableColumnHeader getColumnHeader()
Returns the column header. Note: this is the same object return by getTableHeader().

See Also:
JTable.getTableHeader()

getColumnHeaderFont

public final Font getColumnHeaderFont()
Returns the Font for the column headers


setColumnHeaderFont

public void setColumnHeaderFont(Font f)
Sets the Font for the column headers


getColumnHeaderBackground

public final Color getColumnHeaderBackground()
Returns the background color of the column header.


setColumnHeaderBackground

public void setColumnHeaderBackground(Color val)
Sets the background color of the column header.


getColumnHeaderForeground

public final Color getColumnHeaderForeground()
Returns the color used to draw text of the column header.


setColumnHeaderForeground

public void setColumnHeaderForeground(Color val)
Sets the color used to draw text of the column header.


getColumnHeaderHeight

public final int getColumnHeaderHeight()
Returns the height of the column header.


setColumnHeaderHeight

public void setColumnHeaderHeight(int height)
Sets the height of the column header.


setColumnReorderingAllowed

public void setColumnReorderingAllowed(boolean reorderingAllowed)
Shortcut to set whether the user can drag column headers to reorder columns.

See Also:
JTableHeader.setReorderingAllowed(boolean)

isColumnReorderingAllowed

public final boolean isColumnReorderingAllowed()
Returns true if the user is allowed to rearrange columns by dragging their headers, false otherwise. The default is true. You can rearrange columns programmatically regardless of this setting.

See Also:
JTableHeader.getReorderingAllowed()

setColumnResizingAllowed

public final void setColumnResizingAllowed(boolean resizingAllowed)
Shortcut to set whether the user can resize columns by dragging between headers.

See Also:
JTableHeader.setResizingAllowed(boolean)

isColumnResizingAllowed

public final boolean isColumnResizingAllowed()
Returns true if the user is allowed to resize columns by dragging between their headers, false otherwise. The default is true. You can resize columns programmatically regardless of this setting.

See Also:
JTableHeader.getResizingAllowed()

getColumnProperties

public DsCellProperties getColumnProperties(int col)
Returns the default cell containing the default properties for the column. When rendering a cell first the default properities for the column are applied. Then the default properities for the row are applied followed by the properties specified on the cell itself.


getColumnName

public String getColumnName(int column)
Returns the object used to get the text displayed in the given column header.

Overrides:
getColumnName in class JTable

setColumnName

public void setColumnName(int column,
                          String val)
Sets the text displayed in the column header.


getColumnWidth

public int getColumnWidth(int index)
Determines the width of the specified column in pixels.


setColumnWidth

public void setColumnWidth(int index,
                           int width)
Sets the width of the column at the given index to width.


setColumnWidth

public void setColumnWidth(String columnId,
                           int width)

setColumnWidthToFit

public void setColumnWidthToFit(int column,
                                boolean fitName,
                                boolean fitData)
Sets the width of the column at the given index to fit the text for the name of the column and/or the data in cells in that column.

See Also:
getColumnName(int), setColumnWidth(int, int)

calculateColumnWidthToFit

public int calculateColumnWidthToFit(int column,
                                     boolean fitName,
                                     boolean fitData)
Returns the width of the column at the given index needed to fit the text for the name of the column and/or the data in cells in that column.

See Also:
getColumnName(int), setColumnWidth(int, int), setColumnWidthToFit(int, boolean, boolean)

calculateWidthToFit

public int calculateWidthToFit(boolean fitColumnNames,
                               boolean fitColumnData)
Returns the total width of the table needed to fit the text for the name of the column and/or the data in cells in that column for each column in the table.


setColumnHorizontalAlignment

public void setColumnHorizontalAlignment(int column,
                                         int align)
Sets the horizontal alignment of the text in the column header. Also sets the default horizontal alignment of text in the cells for the column. Valid values are:


setColumnVerticalAlignment

public void setColumnVerticalAlignment(int column,
                                       int align)
Sets the vertical alignment of the text in the column header. Also sets the default vertical alignment of text in the cells for the column. Valid values are:


getColumnCount

public int getColumnCount()
Returns the total number of columns.

Overrides:
getColumnCount in class JTable

getColumn

public TableColumn getColumn(int index)
Returns the TableColumn object for the column at the given position.


getColumn

public TableColumn getColumn(String columnId)

getColumnIndex

public int getColumnIndex(String columnId)
Returns the column index for the column that has the given identifier or column name.


createDefaultColumnsFromModel

public void createDefaultColumnsFromModel()
Overrides:
createDefaultColumnsFromModel in class JTable

addColumn

public TableColumn addColumn()
Adds a column to the end.


addColumn

public TableColumn addColumn(String columnName,
                             String id)
Adds a column to the end with the given name (HeaderValue) and identifier. If the model is a DefaultTableModel or GridModel a column is also added to the model.


addColumn

public void addColumn(TableColumn aColumn)
Appends aColumn to the end of the array of columns held by the column model.

Overrides:
addColumn in class JTable

hideColumn

public void hideColumn(int index)
Removes from the view the column at the given position. The column count in the column model will be decremented. This hides the column from view but allows the data for the column to stay in the model.


setColumnCount

public void setColumnCount(int val)
Sets the total number of columns by adding new columns or removing existing ones.


spanCells

public boolean spanCells(int startRow,
                         int startColumn,
                         int rowsToSpan,
                         int columnsToSpan)
Makes the cell at position startRow, startColumn span across rowsToSpan rows and columnsToSpan columns.

Note: Spanning cells will disable several features such as sorting, column reordering, and hiding columns.

Parameters:
startRow - The row of the cell which will span multiple rows and/or columns
startColumn - The column of the cell which will span multiple rows and/or columns
rowsToSpan - The number of rows to span.
columnsToSpan - The number of columns to span.
See Also:
removeSpan(int, int)

removeSpan

public void removeSpan(int row,
                       int column)
Makes the cell at position row, column not span across multiple rows and/or columns.

Parameters:
row - The row of the cell to remove the span from.
column - The column of the cell to remove the span from.
See Also:
spanCells(int, int, int, int)

getCellRowSpan

protected int getCellRowSpan(int row,
                             int column)

getCellColumnSpan

protected int getCellColumnSpan(int row,
                                int column)

getToolTipText

public String getToolTipText(MouseEvent event)
Overrides JComponent's getToolTipText method in order to allow the cell's tips to be used if it has text set.

Note: if setToolTipText(null) on the DsGrid no tips from the cells will display anymore.

Overrides:
getToolTipText in class JTable
See Also:
JComponent.getToolTipText()

getCellRect

public Rectangle getCellRect(int row,
                             int column,
                             boolean includeSpacing)
Overrides:
getCellRect in class JTable

rowAtPoint

public int rowAtPoint(Point point)
Overrides:
rowAtPoint in class JTable

columnAtPoint

public int columnAtPoint(Point point)
Overrides:
columnAtPoint in class JTable

valueChanged

public void valueChanged(ListSelectionEvent e)
Specified by:
valueChanged in interface ListSelectionListener
Overrides:
valueChanged in class JTable

columnSelectionChanged

public void columnSelectionChanged(ListSelectionEvent e)
Specified by:
columnSelectionChanged in interface TableColumnModelListener
Overrides:
columnSelectionChanged in class JTable

tableChanged

public void tableChanged(TableModelEvent e)
Invoked when this table's TableModel generates a TableModelEvent.

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

Specified by:
tableChanged in interface TableModelListener
Overrides:
tableChanged in class JTable

createDefaultTableHeader

protected JTableHeader createDefaultTableHeader()
Overrides:
createDefaultTableHeader in class JTable

createDefaultRenderers

protected void createDefaultRenderers()
Overrides:
createDefaultRenderers in class JTable

createDefaultEditors

protected void createDefaultEditors()
Overrides:
createDefaultEditors in class JTable

getCellRenderer

public TableCellRenderer getCellRenderer(int row,
                                         int column)
Overrides:
getCellRenderer in class JTable

getCellEditor

public TableCellEditor getCellEditor(int row,
                                     int column)
Overrides:
getCellEditor in class JTable

Diamond Control Suite 3.0

Diamond Edge and Diamond Control Suite are trademarks or registered trademarks of Diamond Edge, Inc. Copyright 1999-2005 Diamond Edge, Inc. All Rights Reserved.