com.sciapp.table
Class AdvancedJTable

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 com.sciapp.table.AdvancedJTable
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, EventListener, Accessible, CellEditorListener, ListSelectionListener, TableColumnModelListener, TableModelListener, Scrollable
Direct Known Subclasses:
TreeTable

public class AdvancedJTable
extends JTable

AdvancedJTable is a sublass of JTable that makes full use of classes contained in this library, so as to add extra functionality to the JTable Swing component.

The most important features that were added are:

1) There is the option to add a dummy column to the table header with no data underneath, for decorative purposes. This option is available if the table is enclosed by an AdvancedJScrollPane, in which case, it can be controlled with setShowDummyColumn.

2) Define default editors and renderers to those in the com.sciapp.editors and com.sciapp.renderers respectively

3) Autoresize table columns upon double-clicking on a table column border. (see TableAssistant)

4) Display a popup through which the columns of the table can be dynamically added/removed. (see TableAssistant)

5) Use a table header whose columns cannot be reordered with right mouse button clicks. (see AdvancedTableHeader)

6) Correctly handle selection changes when the tabular data are restructured. (see TableReorder)

7) Programmatically alter the table columns displayed and their widths. (see setTableState(java.lang.String))


Nested Class Summary
 class AdvancedJTable.InnerTableColumnModel
          InnerTableColumnModel extends DefaultTableColumnModel in order to make the first column of the TreeTable not reorderable (optionally).
protected  class AdvancedJTable.InnerTableHeader
          This class extends FilterTableHeader in order to cater for the last dummy column and to make the first column not reorderable (optionally).
 
Nested classes/interfaces inherited from class javax.swing.JTable
JTable.AccessibleJTable
 
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.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  boolean isFirstColumnFixed
          boolean flag to indicate whether the first column of the table is fixed.
protected  TableReorder tableReorder
          This is the TableReorder object.
 
Fields inherited from class javax.swing.JTable
AUTO_RESIZE_ALL_COLUMNS, AUTO_RESIZE_LAST_COLUMN, AUTO_RESIZE_NEXT_COLUMN, AUTO_RESIZE_OFF, AUTO_RESIZE_SUBSEQUENT_COLUMNS, autoCreateColumnsFromModel, autoResizeMode, cellEditor, cellSelectionEnabled, columnModel, dataModel, defaultEditorsByColumnClass, defaultRenderersByColumnClass, editingColumn, editingRow, editorComp, gridColor, preferredViewportSize, rowHeight, rowMargin, rowSelectionAllowed, selectionBackground, selectionForeground, selectionModel, showHorizontalLines, showVerticalLines, tableHeader
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
AdvancedJTable()
          Constructs a default AdvancedJTable which is initialized with a default data model, a default column model, and a default selection model.
AdvancedJTable(int numRows, int numColumns)
          Constructs an AdvancedJTable with numRows and numColumns of empty cells using the DefaultTableModel.
AdvancedJTable(Object[][] rowData, Object[] columnNames)
          Constructs an AdvancedJTable to display the values in the two dimensional array, rowData, with column names, columnNames.
AdvancedJTable(TableModel dm)
          Constructs a JTable which is initialized with dm as the data model, a default column model, and a default selection model.
AdvancedJTable(TableModel dm, TableColumnModel cm)
          Constructs an AdvancedJTable which is initialized with dm as the data model, cm as the column model, and a default selection model.
AdvancedJTable(TableModel dm, TableColumnModel cm, ListSelectionModel sm)
          Constructs an AdvancedJTable which is initialized with dm as the data model, cm as the column model, and sm as the selection model.
AdvancedJTable(Vector rowData, Vector columnNames)
          Constructs an AdvancedJTable to display the values in the Vector of Vectors, rowData, with column names, columnNames.
 
Method Summary
protected  void configureEnclosingScrollPane()
          If this JTable is the viewportView of an enclosing JScrollPane (the usual situation), configure this ScrollPane by, amongst other things, installing the table's tableHeader as the columnHeaderView of the scroll pane.
protected  TableColumnModel createDefaultColumnModel()
          Returns a new instance of InnerTableColumnModel.
 void createDefaultColumnsFromModel()
          Creates default columns for the table from the data model using the getColumnCount method defined in the TableModel interface.
protected  void createDefaultEditors()
          Creates default cell editors for objects, numbers, and boolean values.
protected  void createDefaultRenderers()
          Creates default cell renderers for objects, numbers, doubles, dates, booleans, and icons.
protected  JTableHeader createDefaultTableHeader()
          Returns the default table header object which is a customized AdvancedTableHeader (InnerTableHeader), that takes into account the last dummy column.
protected  TableReorder createReorder()
          Returns the TableReorder that will handle table selection changes.
 Class getColumnClass(int column)
          Returns the type of the column appearing in the view at column position column.
 boolean getShowDummyColumn()
          Determines whether the table is set to show the dummy column.
 TableAssistant getTableAssistant()
          Returns the table assistant instance associated with this table.
 String getTableState()
          Returns a string showing which columns are shown and their corresponding widths.
 Object getValueAt(int row, int column)
          Returns the cell value at row and column.
protected  void initializeLocalVars()
          Initializes table properties to their default values.
 boolean isCellEditable(int row, int column)
          Returns true if the cell at row and column is editable.
 boolean isDummyColumn(int column)
          Determines if the supplied column is the last dummy column.
 boolean isFirstColumnFixed()
          Determines whether the first column of the table can be removed or reordered.
 Component prepareRenderer(TableCellRenderer renderer, int row, int column)
          Prepares the renderer by querying the data model for the value and selection state of the cell at row, column.
 void scrollRectToVisible(Rectangle aRect)
          Forwards the scrollRectToVisible() message to the JComponent's parent.
 void setColumnModel(TableColumnModel newModel)
          Sets the column model for this table to newModel and registers for listener notifications from the new column model.
 void setEvenColor(Color evenColor)
          Sets the color for painting the even rows of the table to all the renderers contained in the defaultRenderersByColumnClass Hashtable (provided the renderer is an instance of DefaultRenderer.
 void setFirstColumnFixed(boolean isFirstColumnFixed)
          Assigns a boolean flag that is true if the first column of the table can be removed or reordered.
 void setModel(TableModel model)
          Sets the data model for this table to newModel and registers with it for listener notifications from the new data model.
 void setOddColor(Color oddColor)
          Sets the color for painting the odd rows of the table to all the renderers contained in the defaultRenderersByColumnClass Hashtable (provided the renderer is an instance of DefaultRenderer.
 void setShowDummyColumn(boolean showDummyColumn)
          Sets this table's showLastColumn flag.
 void setTableHeader(JTableHeader newHeader)
          Sets the tableHeader working with this JTable to newHeader.
 void setTableState(String state)
          Set which columns will be shown and their corresponding widths.
 void tableChanged(TableModelEvent e)
          Invoked when this table's TableModel generates a TableModelEvent.
 void updateUI()
          Notification from the UIManager that the L&F has changed.
 
Methods inherited from class javax.swing.JTable
addColumn, addColumnSelectionInterval, addNotify, addRowSelectionInterval, changeSelection, clearSelection, columnAdded, columnAtPoint, columnMarginChanged, columnMoved, columnRemoved, columnSelectionChanged, convertColumnIndexToModel, convertColumnIndexToView, createDefaultDataModel, createDefaultSelectionModel, createScrollPaneForTable, doLayout, editCellAt, editCellAt, editingCanceled, editingStopped, getAccessibleContext, getAutoCreateColumnsFromModel, getAutoResizeMode, getCellEditor, getCellEditor, getCellRect, getCellRenderer, getCellSelectionEnabled, getColumn, getColumnCount, getColumnModel, getColumnName, getColumnSelectionAllowed, getDefaultEditor, getDefaultRenderer, getDragEnabled, getEditingColumn, getEditingRow, getEditorComponent, getGridColor, getIntercellSpacing, getModel, getPreferredScrollableViewportSize, getRowCount, getRowHeight, getRowHeight, getRowMargin, getRowSelectionAllowed, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedColumn, getSelectedColumnCount, getSelectedColumns, getSelectedRow, getSelectedRowCount, getSelectedRows, getSelectionBackground, getSelectionForeground, getSelectionModel, getShowHorizontalLines, getShowVerticalLines, getSurrendersFocusOnKeystroke, getTableHeader, getToolTipText, getUI, getUIClassID, isCellSelected, isColumnSelected, isEditing, isRowSelected, moveColumn, paramString, prepareEditor, processKeyBinding, removeColumn, removeColumnSelectionInterval, removeEditor, removeNotify, removeRowSelectionInterval, resizeAndRepaint, rowAtPoint, selectAll, setAutoCreateColumnsFromModel, setAutoResizeMode, setCellEditor, setCellSelectionEnabled, setColumnSelectionAllowed, setColumnSelectionInterval, setDefaultEditor, setDefaultRenderer, setDragEnabled, setEditingColumn, setEditingRow, setGridColor, setIntercellSpacing, setPreferredScrollableViewportSize, setRowHeight, setRowHeight, setRowMargin, setRowSelectionAllowed, setRowSelectionInterval, setSelectionBackground, setSelectionForeground, setSelectionMode, setSelectionModel, setShowGrid, setShowHorizontalLines, setShowVerticalLines, setSurrendersFocusOnKeystroke, setUI, setValueAt, sizeColumnsToFit, sizeColumnsToFit, unconfigureEnclosingScrollPane, valueChanged
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, 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, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, 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, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, 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, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

tableReorder

protected transient TableReorder tableReorder
This is the TableReorder object.


isFirstColumnFixed

protected boolean isFirstColumnFixed
boolean flag to indicate whether the first column of the table is fixed.

Constructor Detail

AdvancedJTable

public AdvancedJTable()
Constructs a default AdvancedJTable which is initialized with a default data model, a default column model, and a default selection model.


AdvancedJTable

public AdvancedJTable(Object[][] rowData,
                      Object[] columnNames)
Constructs an AdvancedJTable to display the values in the two dimensional array, rowData, with column names, columnNames. rowData is an Array of rows, so the value of the cell at row 1, column 5 can be obtained with the following code:

 rowData[1][5]; 

All rows must be of the same length as columnNames.


AdvancedJTable

public AdvancedJTable(int numRows,
                      int numColumns)
Constructs an AdvancedJTable with numRows and numColumns of empty cells using the DefaultTableModel. The columns will have names of the form "A", "B", "C", etc.


AdvancedJTable

public AdvancedJTable(Vector rowData,
                      Vector columnNames)
Constructs an AdvancedJTable to display the values in the Vector of Vectors, rowData, with column names, columnNames. The Vectors contained in rowData should contain the values for that row. In other words, the value of the cell at row 1, column 5 can be obtained with the following code:

((Vector)rowData.elementAt(1)).elementAt(5);

All rows must be of the same length as columnNames.


AdvancedJTable

public AdvancedJTable(TableModel dm)
Constructs a JTable which is initialized with dm as the data model, a default column model, and a default selection model.


AdvancedJTable

public AdvancedJTable(TableModel dm,
                      TableColumnModel cm)
Constructs an AdvancedJTable which is initialized with dm as the data model, cm as the column model, and a default selection model.


AdvancedJTable

public AdvancedJTable(TableModel dm,
                      TableColumnModel cm,
                      ListSelectionModel sm)
Constructs an AdvancedJTable which is initialized with dm as the data model, cm as the column model, and sm as the selection model. If any of the parameters are null this method will initialize the table with the corresponding default model. The autoCreateColumnsFromModel flag is set to false if cm is non-null, otherwise it is set to true and the column model is populated with suitable TableColumns for the columns in dm.

Method Detail

configureEnclosingScrollPane

protected void configureEnclosingScrollPane()
If this JTable is the viewportView of an enclosing JScrollPane (the usual situation), configure this ScrollPane by, amongst other things, installing the table's tableHeader as the columnHeaderView of the scroll pane. When a JTable is added to a JScrollPane in the usual way, using new JScrollPane(myTable), addNotify is called in the JTable (when the table is added to the viewport). JTable's addNotify method in turn calls this method, which is protected so that this default installation procedure can be overridden by a subclass.

Overrides:
configureEnclosingScrollPane in class JTable
See Also:
JTable.addNotify()

createDefaultColumnModel

protected TableColumnModel createDefaultColumnModel()
Returns a new instance of InnerTableColumnModel. Returns the default column model object, which is a DefaultTableColumnModel. A subclass can override this method to return a different column model object.

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

createDefaultColumnsFromModel

public void createDefaultColumnsFromModel()
Creates default columns for the table from the data model using the getColumnCount method defined in the TableModel interface.

Clears any existing columns before creating the new columns based on information from the model.

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

createDefaultEditors

protected void createDefaultEditors()
Creates default cell editors for objects, numbers, and boolean values.

Overrides:
createDefaultEditors in class JTable
See Also:
DefaultCellEditor

createDefaultRenderers

protected void createDefaultRenderers()
Creates default cell renderers for objects, numbers, doubles, dates, booleans, and icons.

Overrides:
createDefaultRenderers in class JTable
See Also:
DefaultTableCellRenderer

createDefaultTableHeader

protected JTableHeader createDefaultTableHeader()
Returns the default table header object which is a customized AdvancedTableHeader (InnerTableHeader), that takes into account the last dummy column.

Overrides:
createDefaultTableHeader in class JTable
Returns:
the default table header object
See Also:
JTableHeader

createReorder

protected TableReorder createReorder()
Returns the TableReorder that will handle table selection changes.

Returns:
the TableReorder object

getColumnClass

public Class getColumnClass(int column)
Returns the type of the column appearing in the view at column position column.

Overrides:
getColumnClass in class JTable
Parameters:
column - the column in the view being queried
Returns:
the type of the column at position column in the view where the first column is column 0

getShowDummyColumn

public boolean getShowDummyColumn()
Determines whether the table is set to show the dummy column. Note that if the value returned is true, this does not guarantee that the dummy column is shown, since the table must also be enclosed by an AdvancedJScrollPane.

Returns:
true if the table is set to show the last column, false otherwise.

getTableAssistant

public TableAssistant getTableAssistant()
Returns the table assistant instance associated with this table.

Returns:
the table assistant.

getTableState

public String getTableState()
Returns a string showing which columns are shown and their corresponding widths. The string is formatted as follows: i1:w1,i2:w2,... where i is the column's model index and w its width.

Returns:
a string showing which columns are shown and their corresponding widths.

getValueAt

public Object getValueAt(int row,
                         int column)
Returns the cell value at row and column.

Note: The column is specified in the table view's display order, and not in the TableModel's column order. This is an important distinction because as the user rearranges the columns in the table, the column at a given index in the view will change. Meanwhile the user's actions never affect the model's column ordering.

Overrides:
getValueAt in class JTable
Parameters:
row - the row whose value is to be queried
column - the column whose value is to be queried
Returns:
the Object at the specified cell

initializeLocalVars

protected void initializeLocalVars()
Initializes table properties to their default values.

Overrides:
initializeLocalVars in class JTable

isCellEditable

public boolean isCellEditable(int row,
                              int column)
Returns true if the cell at row and column is editable. Otherwise, invoking setValueAt on the cell will have no effect.

Note: The column is specified in the table view's display order, and not in the TableModel's column order. This is an important distinction because as the user rearranges the columns in the table, the column at a given index in the view will change. Meanwhile the user's actions never affect the model's column ordering.

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

isDummyColumn

public boolean isDummyColumn(int column)
Determines if the supplied column is the last dummy column.

Parameters:
column - the index of the table column
Returns:
true if the supplied column is the last dummy column, false otherwise.

isFirstColumnFixed

public boolean isFirstColumnFixed()
Determines whether the first column of the table can be removed or reordered.

Returns:
true if we can remove or reorder the first column, false otherwise.

prepareRenderer

public Component prepareRenderer(TableCellRenderer renderer,
                                 int row,
                                 int column)
Description copied from class: javax.swing.JTable
Prepares the renderer by querying the data model for the value and selection state of the cell at row, column. Returns the component (may be a Component or a JComponent) under the event location.

Note: Throughout the table package, the internal implementations always use this method to prepare renderers so that this default behavior can be safely overridden by a subclass.

Overrides:
prepareRenderer in class JTable
Parameters:
renderer - the TableCellRenderer to prepare
row - the row of the cell to render, where 0 is the first row
column - the column of the cell to render, where 0 is the first column
Returns:
the Component under the event location

scrollRectToVisible

public void scrollRectToVisible(Rectangle aRect)
Forwards the scrollRectToVisible() message to the JComponent's parent. Components that can service the request, such as JViewport, override this method and perform the scrolling.

Overrides:
scrollRectToVisible in class JComponent
Parameters:
aRect - the visible Rectangle
See Also:
JViewport

setColumnModel

public void setColumnModel(TableColumnModel newModel)
Sets the column model for this table to newModel and registers for listener notifications from the new column model. Also sets the column model of the JTableHeader to columnModel.

Overrides:
setColumnModel in class JTable
Parameters:
newModel - the new data source for this table
See Also:
JTable.getColumnModel()

setEvenColor

public void setEvenColor(Color evenColor)
Sets the color for painting the even rows of the table to all the renderers contained in the defaultRenderersByColumnClass Hashtable (provided the renderer is an instance of DefaultRenderer.

Parameters:
evenColor - the even row color

setFirstColumnFixed

public void setFirstColumnFixed(boolean isFirstColumnFixed)
Assigns a boolean flag that is true if the first column of the table can be removed or reordered.

Parameters:
isFirstColumnFixed - a boolean which is true if we are able to remove or reorder the first column.

setModel

public void setModel(TableModel model)
Sets the data model for this table to newModel and registers with it for listener notifications from the new data model.

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

setOddColor

public void setOddColor(Color oddColor)
Sets the color for painting the odd rows of the table to all the renderers contained in the defaultRenderersByColumnClass Hashtable (provided the renderer is an instance of DefaultRenderer.

Parameters:
oddColor - the odd row color

setShowDummyColumn

public void setShowDummyColumn(boolean showDummyColumn)
Sets this table's showLastColumn flag. Note that even if showLastColumn is true, this does not guarantee that the last column will be actually shown.


setTableHeader

public void setTableHeader(JTableHeader newHeader)
Sets the tableHeader working with this JTable to newHeader. It is legal to have a null tableHeader.

Overrides:
setTableHeader in class JTable
Parameters:
newHeader - new tableHeader
See Also:
JTable.getTableHeader()

setTableState

public void setTableState(String state)
Set which columns will be shown and their corresponding widths. state is formatted as follows: i1:w1,i2:w2,... where i is the column's model index and w its width. A column which is removed by calling this method can always be added later if its model index is supplied. Only columns that are removed via the removeColumn method of JTable are permanently removed from the table.

Parameters:
state - a string showing which columns will be shown and their corresponding widths.

tableChanged

public void tableChanged(TableModelEvent e)
Invoked when this table's TableModel generates a TableModelEvent. The TableModelEvent should be constructed in the coordinate system of the model; the appropriate mapping to the view coordinate system is performed by this JTable when it receives the event.

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

Note that as of 1.3, this method clears the selection, if any.

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

updateUI

public void updateUI()
Notification from the UIManager that the L&F has changed. Replaces the current UI object with the latest version from the UIManager.

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