JIDE 3.5.15

com.jidesoft.grid
Class TableScrollPane

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JScrollPane
                  extended by com.jidesoft.swing.JideScrollPane
                      extended by com.jidesoft.grid.TableScrollPane
All Implemented Interfaces:
TableAdapter, JideScrollPaneConstants, ImageObserver, MenuContainer, Serializable, Accessible, ScrollPaneConstants
Direct Known Subclasses:
AggregateTablePane

public class TableScrollPane
extends JideScrollPane
implements TableAdapter

TableScrollPane is a special JideScrollPane that supports header and footer columns or rows. JScrollPane supports adding a component to top area and west area. JideScrollPane added the support to east area and bottom area. TableScrollPane further enhances it to handle the special case of table to allow you easily add header column(s), footer column(s), and footer to your table.

To use it, you need to create a MultiTableModel instance first. Defining MultiTableModel is the same as defining TableModel except you can specify which columns are header and footer.

After you create MultiTableModel, just pass it in to the constructor of TableScrollPane. You have an option to specify if the table is sortable. You also have an option to specify a table model for footer row. The table created from footer table model will appear at the bottom of the table and scroll horizontally along with the table above. The footer table model must have the same column count as the MultiTableModel excluding header and footer columns.

Even though header columns and footer columns are added as separate components, they will work just like in one table. For example, row selection is synchronized. Tab key or left/right arrows will navigate across all three tables. If you scroll vertically, all three tables will scroll together. If you resize columns in any table, even the last column of the header column table and the first column of footer column table.

Note for users of TableScrollPane before v1.8.6:In 1.8.6 release, there is a design change in TableScrollPane. The old constructor that takes six table models as parameter is removed. The new constructors only accept one or two MultiTableModels. If you use six table model constructor, you need to refactor your code to remove the usage of it.

See Also:
JideScrollPane, MultiTableModel, Serialized Form

Nested Class Summary
static class TableScrollPane.TablePosition
          A class that define a table, a row index and a column index.
 
Nested classes/interfaces inherited from class javax.swing.JScrollPane
JScrollPane.AccessibleJScrollPane, JScrollPane.ScrollBar
 
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  JTable _columnFooterTable
           
protected  JTable _columnHeaderTable
           
protected  boolean _columnSelectionAllowed
          True if column selection is allowed in this table.
protected  JTable _mainTable
           
protected  boolean _nonContiguousCellSelectionAllowed
          True if non-contiguous selection is allowed in this table.
protected  MultiTableModel _originalFooterTableModel
           
protected  MultiTableModel _originalHeaderTableModel
           
protected  MultiTableModel _originalTableModel
           
protected  JTable _rowFooterColumnFooterTable
           
protected  JTable _rowFooterColumnHeaderTable
           
protected  JTable _rowFooterTable
           
protected  JTable _rowHeaderColumnFooterTable
           
protected  JTable _rowHeaderColumnHeaderTable
           
protected  JTable _rowHeaderTable
           
protected  boolean _rowSelectionAllowed
          True if row selection is allowed in this table scroll pane.
static String AUTO_UPDATE_FOOTER_TABLE_COLUMNS
          By default we will try to automatically update footer table when main table column is added, removed or moved.
static String COLUMNFOOTER_TABLE
           
static String COLUMNHEADER_TABLE
           
static String MAIN_TABLE
           
static String PROPERTY_TABLE_MODEL
           
static String ROWFOOTER_COLUMNFOOTER_TABLE
           
static String ROWFOOTER_COLUMNHEADER_TABLE
           
static String ROWFOOTER_TABLE
           
static String ROWHEADER_COLUMNFOOTER_TABLE
           
static String ROWHEADER_COLUMNHEADER_TABLE
           
static String ROWHEADER_TABLE
           
static String TABLE_KEY
          The client property name of all the tables created by TableScrollPane.
static String TABLESCROLLPANE_KEY
           
 
Fields inherited from class com.jidesoft.swing.JideScrollPane
_columnFooter, _hLeft, _hRight, _rowFooter, _subColumnHeader, _subUpperLeft, _subUpperRight, _vBottom, _vTop, CLIENT_PROPERTY_MASTER_VIEWPORT, CLIENT_PROPERTY_SLAVE_VIEWPORT, PROPERTY_COLUMN_FOOTERS_HEIGHT_UNIFIED, PROPERTY_COLUMN_HEADERS_HEIGHT_UNIFIED, PROPERTY_FLAT_LAYOUT, PROPERTY_HORIZONTAL_SCROLL_BAR_COVERS_WHOLE_WIDTH, PROPERTY_KEEP_CORNER_VISIBLE, PROPERTY_VERTICAL_SCROLL_BAR_COVERS_WHOLE_HEIGHT
 
Fields inherited from class javax.swing.JScrollPane
columnHeader, horizontalScrollBar, horizontalScrollBarPolicy, lowerLeft, lowerRight, rowHeader, upperLeft, upperRight, verticalScrollBar, verticalScrollBarPolicy, viewport
 
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 com.jidesoft.swing.JideScrollPaneConstants
COLUMN_FOOTER, HORIZONTAL_LEADING, HORIZONTAL_LEFT, HORIZONTAL_RIGHT, HORIZONTAL_TRAILING, ROW_FOOTER, SUB_COLUMN_HEADER, SUB_UPPER_LEFT, SUB_UPPER_RIGHT, VERTICAL_BOTTOM, VERTICAL_TOP
 
Fields inherited from interface javax.swing.ScrollPaneConstants
COLUMN_HEADER, HORIZONTAL_SCROLLBAR, HORIZONTAL_SCROLLBAR_ALWAYS, HORIZONTAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_NEVER, HORIZONTAL_SCROLLBAR_POLICY, LOWER_LEADING_CORNER, LOWER_LEFT_CORNER, LOWER_RIGHT_CORNER, LOWER_TRAILING_CORNER, ROW_HEADER, UPPER_LEADING_CORNER, UPPER_LEFT_CORNER, UPPER_RIGHT_CORNER, UPPER_TRAILING_CORNER, VERTICAL_SCROLLBAR, VERTICAL_SCROLLBAR_ALWAYS, VERTICAL_SCROLLBAR_AS_NEEDED, VERTICAL_SCROLLBAR_NEVER, VERTICAL_SCROLLBAR_POLICY, VIEWPORT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
TableScrollPane()
          Creates an empty TableScrollPane.
TableScrollPane(MultiTableModel tableModel)
          Creates a TableScrollPane.
TableScrollPane(MultiTableModel tableModel, boolean sortable)
          Creates a TableScrollPane without footer table.
TableScrollPane(MultiTableModel tableModel, MultiTableModel footerTableModel)
          Creates a TableScrollPane with a footer table.
TableScrollPane(MultiTableModel tableModel, MultiTableModel footerTableModel, boolean sortable)
          Creates a TableScrollPane with a footer table.
TableScrollPane(MultiTableModel tableModel, MultiTableModel footerTableModel, boolean sortable, boolean sync)
          Creates a TableScrollPane with a footer table.
TableScrollPane(MultiTableModel tableModel, MultiTableModel footerTableModel, boolean sortable, int tableIndex, boolean sync)
          Creates a TableScrollPane with a footer table.
TableScrollPane(MultiTableModel tableModel, MultiTableModel headerTableModel, MultiTableModel footerTableModel)
          Creates a TableScrollPane with a header table and a footer table.
TableScrollPane(MultiTableModel tableModel, MultiTableModel headerTableModel, MultiTableModel footerTableModel, boolean sortable)
          Creates a TableScrollPane with a header table and a footer table.
TableScrollPane(MultiTableModel tableModel, MultiTableModel headerTableModel, MultiTableModel footerTableModel, boolean sortable, boolean sync)
          Creates a TableScrollPane with a header table and a footer table.
TableScrollPane(MultiTableModel tableModel, MultiTableModel headerTableModel, MultiTableModel footerTableModel, boolean sortable, int tableIndex, boolean sync)
          Creates a TableScrollPane with a header table and a footer table.
 
Method Summary
 void changeSelection(int rowIndex, int columnIndex, boolean toggle, boolean extend)
          Updates the selection models of the table, depending on the state of the two flags: toggle and extend.
 void clearSelection()
          Deselects all selected columns and rows.
 int convertColumnIndexToModel(int viewIndex)
          Convert the view column index in the entire TableScrollPane to model index.
 int convertColumnIndexToView(int modelIndex)
          Convert the view column index in the entire TableScrollPane to model index.
protected  TableModel createSortableTableModel(MultiTableModel tableModel, boolean sortable)
          Creates a SortableTableModel or SortableTreeTableModel for the MultiTableModel if isSortable() is true.
protected  JTable createTable(TableModel model, boolean sortable)
          Creates the table.
protected  JTable createTable(TableModel model, boolean sortable, int type)
          Creates the table.
protected  JTable createTable(TableModel model, boolean sortable, int type, boolean columnFooter, int tableIndex)
          Creates the table.
protected  JTable createTable(TableModel model, boolean sortable, int type, int tableIndex)
          Deprecated. We added a footer parameter to the createTable method. This method was left here for backward compatible reason. Please change your code to override createTable(javax.swing.table.TableModel, boolean, int) instead.
protected  void customizeTable(JTable table)
          Customizes the table created by TableScrollPane.
 JTable[] getAllChildTables()
          Gets all child tables in an array.
 TableCellEditor getCellEditor()
           
 boolean getCellSelectionEnabled()
          Returns true if both row and column selection models are enabled.
 Class<?> getColumnClass(int column)
          Returns the type of the column appearing in the view at column position column.
 int getColumnCount()
          Gets the total column count of TableScrollPane.
 JTable getColumnFooterTable()
          The column footer table.
 JTable getColumnHeaderTable()
           
 String getColumnName(int column)
          Returns the name of the column appearing in the view at column position column.
 boolean getColumnSelectionAllowed()
          Returns true if columns can be selected.
 JTable getEditingTable()
           
 MultiTableModel getFooterTableModel()
           
 JTable getMainTable()
          The main table.
 MultiTableModel getModel()
          Gets the original table model that is passed in constructors.
 Printable getPrintable(JTable.PrintMode printMode, MessageFormat headerFormat, MessageFormat footerFormat)
          Return a Printable for use in printing this JTable.
 int getRowCount()
          Gets the total row count of TableScrollPane.
 JTable getRowFooterColumnFooterTable()
          Gets the row footer of the column footer table.
 JTable getRowFooterColumnHeaderTable()
           
 JTable getRowFooterTable()
          The row footer table.
 JTable getRowHeaderColumnFooterTable()
          Gets the row header of the column footer table.
 JTable getRowHeaderColumnHeaderTable()
           
 JTable getRowHeaderTable()
          The row header table.
 boolean getRowSelectionAllowed()
          Returns true if rows can be selected.
 int getSelectedColumn()
          Returns the index of the first selected column, -1 if no column is selected.
 int getSelectedColumnCount()
          Returns the number of selected columns.
 int[] getSelectedColumns()
          Returns the indices of all selected columns.
 int getSelectedRow()
          Returns the index of the first selected row, -1 if no row is selected.
 int getSelectedRowCount()
          Returns the number of selected rows.
 int[] getSelectedRows()
          Returns the indices of all selected rows.
 TableScrollPane.TablePosition getTableAtCell(int row, int column)
          Gets the table as the specified row and column index.
 TableScrollPane.TablePosition getTableAtColumn(int column)
          Gets the table as the specified column index.
 TableScrollPane.TablePosition getTableAtRow(int row)
          Gets the table as the specified row index.
 TableCustomizer getTableCustomizer()
          Gets the table customizer.
 MultiTableModel getTableModel()
          Gets the original table model that is passed in constructors.
 Object getValueAt(int row, int column)
          Returns the cell value at row and column.
 boolean isAllowMultiSelectionInDifferentTable()
          Get the flag indicating if the TableScrollPane allow select multiple rows in different tables, including main table and column footer table for example.
 boolean isCellEditable(int row, int column)
          Returns true if the cell at row and column is editable.
 boolean isCellSelected(int row, int column)
          Returns true if the specified indices are in the valid range of rows and columns and the cell at the specified position is selected.
 boolean isColumnSelected(int column)
          Returns true if the specified index is in the valid range of columns, and the column at that index is selected.
 boolean isEditing()
           
 boolean isNonContiguousCellSelectionAllowed()
          Returns true if non-contiguous cell selection can be selected.
 boolean isRowSelected(int row)
          Returns true if the specified index is in the valid range of rows, and the row at that index is selected.
 boolean isSortable()
           
 boolean print()
          A convenience method that displays a printing dialog, and then prints this JTable in mode PrintMode.FIT_WIDTH, with no header or footer text.
 boolean print(JTable.PrintMode printMode)
          A convenience method that displays a printing dialog, and then prints this JTable in the given printing mode, with no header or footer text.
 boolean print(JTable.PrintMode printMode, MessageFormat headerFormat, MessageFormat footerFormat)
          A convenience method that displays a printing dialog, and then prints this JTable in the given printing mode, with the specified header and footer text.
 boolean print(JTable.PrintMode printMode, MessageFormat headerFormat, MessageFormat footerFormat, boolean showPrintDialog, PrintRequestAttributeSet attr, boolean interactive)
          Prints this table with the default printer specified as the print service.
 boolean print(JTable.PrintMode printMode, MessageFormat headerFormat, MessageFormat footerFormat, boolean showPrintDialog, PrintRequestAttributeSet attr, boolean interactive, PrintService service)
          Prints this JTable.
 void refreshColumns()
          Calls this method when getColumnType value changed in MultiTableModel.
protected  void removeExtraColumns(JTable table, int type, int tableIndex)
          Removes extra columns from TableColumnModel that doesn't match with the type and tableIndex.
 void resizeRowHeaderTableToFit()
          Resizes the row header table to fix the gap between the main table, if any.
protected  void resynchronizeTablesSelection()
           
 void setAllowMultiSelectionInDifferentTable(boolean allowMultiSelectionInDifferentTable)
          Set the flag indicating if the TableScrollPane allow select multiple rows in different tables, including main table and column footer table for example.
 void setCellSelectionEnabled(boolean cellSelectionEnabled)
          Sets whether this table allows both a column selection and a row selection to exist simultaneously.
 void setColumnSelectionAllowed(boolean columnSelectionAllowed)
          Sets whether the columns in this model can be selected.
 void setFooterTableModel(MultiTableModel footerTableModel)
          Sets the footer table model.
 void setHeaderTableModel(MultiTableModel headerTableModel)
          Sets the header table model.
 void setNonContiguousCellSelectionAllowed(boolean nonContiguousCellSelectionAllowed)
          Sets whether non-contiguous cell selection in this model can be selected.
 void setRowSelectionAllowed(boolean rowSelectionAllowed)
          Sets whether the rows in this model can be selected.
 void setSortable(boolean sortable)
           
 void setTableCustomizer(TableCustomizer tableCustomizer)
          Sets the table customizer.
 void setTableModel(MultiTableModel tableModel)
          Sets the original table model and recreates all child tables.
 void setValueAt(Object aValue, int row, int column)
          Sets the value for the cell in the table model at row and column.
 
Methods inherited from class com.jidesoft.swing.JideScrollPane
getColumnFooter, getCorner, getRowFooter, getScrollBarCorner, getSubColumnHeader, isColumnFootersHeightUnified, isColumnHeadersHeightUnified, isFlatLayout, isHorizontalScrollBarCoversWholeWidth, isKeepCornerVisible, isVerticalScrollBarCoversWholeHeight, setColumnFooter, setColumnFootersHeightUnified, setColumnFooterView, setColumnHeader, setColumnHeadersHeightUnified, setCorner, setFlatLayout, setHorizontalScrollBarCoversWholeWidth, setKeepCornerVisible, setLayout, setRowFooter, setRowFooterView, setRowHeader, setScrollBarCorner, setSubColumnHeader, setSubColumnHeaderView, setVerticalScrollBarCoversWholeHeight, setViewport, updateUI
 
Methods inherited from class javax.swing.JScrollPane
createHorizontalScrollBar, createVerticalScrollBar, createViewport, getAccessibleContext, getColumnHeader, getHorizontalScrollBar, getHorizontalScrollBarPolicy, getRowHeader, getUI, getUIClassID, getVerticalScrollBar, getVerticalScrollBarPolicy, getViewport, getViewportBorder, getViewportBorderBounds, isValidateRoot, isWheelScrollingEnabled, paramString, setColumnHeaderView, setComponentOrientation, setHorizontalScrollBar, setHorizontalScrollBarPolicy, setRowHeaderView, setUI, setVerticalScrollBar, setVerticalScrollBarPolicy, setViewportBorder, setViewportView, setWheelScrollingEnabled
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, 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, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, 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, doLayout, 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, 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, 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

_originalTableModel

protected MultiTableModel _originalTableModel

_originalFooterTableModel

protected MultiTableModel _originalFooterTableModel

_originalHeaderTableModel

protected MultiTableModel _originalHeaderTableModel

_mainTable

protected JTable _mainTable

_rowHeaderTable

protected JTable _rowHeaderTable

_rowFooterTable

protected JTable _rowFooterTable

_columnFooterTable

protected JTable _columnFooterTable

_rowHeaderColumnFooterTable

protected JTable _rowHeaderColumnFooterTable

_rowFooterColumnFooterTable

protected JTable _rowFooterColumnFooterTable

_columnHeaderTable

protected JTable _columnHeaderTable

_rowHeaderColumnHeaderTable

protected JTable _rowHeaderColumnHeaderTable

_rowFooterColumnHeaderTable

protected JTable _rowFooterColumnHeaderTable

TABLE_KEY

public static final String TABLE_KEY
The client property name of all the tables created by TableScrollPane. The six possible values are defined below. The value can be retrieved by table.getClientProperty(TableScrollPane.TABLE_KEY);

See Also:
Constant Field Values

TABLESCROLLPANE_KEY

public static final String TABLESCROLLPANE_KEY
See Also:
Constant Field Values

MAIN_TABLE

public static final String MAIN_TABLE
See Also:
Constant Field Values

ROWHEADER_TABLE

public static final String ROWHEADER_TABLE
See Also:
Constant Field Values

ROWFOOTER_TABLE

public static final String ROWFOOTER_TABLE
See Also:
Constant Field Values

COLUMNFOOTER_TABLE

public static final String COLUMNFOOTER_TABLE
See Also:
Constant Field Values

ROWHEADER_COLUMNFOOTER_TABLE

public static final String ROWHEADER_COLUMNFOOTER_TABLE
See Also:
Constant Field Values

ROWFOOTER_COLUMNFOOTER_TABLE

public static final String ROWFOOTER_COLUMNFOOTER_TABLE
See Also:
Constant Field Values

COLUMNHEADER_TABLE

public static final String COLUMNHEADER_TABLE
See Also:
Constant Field Values

ROWHEADER_COLUMNHEADER_TABLE

public static final String ROWHEADER_COLUMNHEADER_TABLE
See Also:
Constant Field Values

ROWFOOTER_COLUMNHEADER_TABLE

public static final String ROWFOOTER_COLUMNHEADER_TABLE
See Also:
Constant Field Values

PROPERTY_TABLE_MODEL

public static final String PROPERTY_TABLE_MODEL
See Also:
Constant Field Values

AUTO_UPDATE_FOOTER_TABLE_COLUMNS

public static final String AUTO_UPDATE_FOOTER_TABLE_COLUMNS
By default we will try to automatically update footer table when main table column is added, removed or moved. If you want to handle the update yourself and don't want this auto-update to happen, you can call getMainTable().putClientProperty(TableScrollPane.AUTO_UPDATE_FOOTER_TABLE_COLUMNS, Boolean.FALSE).

See Also:
Constant Field Values

_rowSelectionAllowed

protected boolean _rowSelectionAllowed
True if row selection is allowed in this table scroll pane.


_columnSelectionAllowed

protected boolean _columnSelectionAllowed
True if column selection is allowed in this table.


_nonContiguousCellSelectionAllowed

protected boolean _nonContiguousCellSelectionAllowed
True if non-contiguous selection is allowed in this table.

Constructor Detail

TableScrollPane

public TableScrollPane()
Creates an empty TableScrollPane. You can call setTableModel(com.jidesoft.grid.MultiTableModel) to set a non-empty table model later.


TableScrollPane

public TableScrollPane(MultiTableModel tableModel)
Creates a TableScrollPane. The tables will not be sortable.

Parameters:
tableModel - the MultiTableModel. This is the main table model that will be used to create up to three tables in TableScrollPane.

TableScrollPane

public TableScrollPane(MultiTableModel tableModel,
                       MultiTableModel footerTableModel)
Creates a TableScrollPane with a footer table. The tables will not be sortable.

Parameters:
tableModel - the MultiTableModel. This is the main table model that will be used to create upto three tables in TableScrollPane.
footerTableModel - the footer table model. It will be used to create a footer table below the main table. It must have the same column count as the MultiTableModel's non-header and non-footer column count.

TableScrollPane

public TableScrollPane(MultiTableModel tableModel,
                       MultiTableModel footerTableModel,
                       boolean sortable)
Creates a TableScrollPane with a footer table. You can specify if the tables are sortable.

Parameters:
tableModel - the MultiTableModel. This is the main table model that will be used to create upto three tables in TableScrollPane.
footerTableModel - the footer table model. It will be used to create a footer table below the main table. It must have the same column count as the MultiTableModel's non-header and non-footer column count.
sortable - if the tables will be sortable.

TableScrollPane

public TableScrollPane(MultiTableModel tableModel,
                       MultiTableModel headerTableModel,
                       MultiTableModel footerTableModel)
Creates a TableScrollPane with a header table and a footer table. The tables will not be sortable.

Parameters:
tableModel - the MultiTableModel. This is the main table model that will be used to create up to three tables in TableScrollPane.
headerTableModel - the header table model. It will be used to create a header table below the normal table header. It must have the same column count as the MultiTableModel's non-header and non-footer column count.
footerTableModel - the footer table model. It will be used to create a footer table below the main table. It must have the same column count as the MultiTableModel's non-header and non-footer column count.

TableScrollPane

public TableScrollPane(MultiTableModel tableModel,
                       MultiTableModel headerTableModel,
                       MultiTableModel footerTableModel,
                       boolean sortable)
Creates a TableScrollPane with a header table and a footer table. You can specify if the tables are sortable.

Parameters:
tableModel - the MultiTableModel. This is the main table model that will be used to create up to three tables in TableScrollPane.
headerTableModel - the header table model. It will be used to create a header table below the normal table header. It must have the same column count as the MultiTableModel's non-header and non-footer column count.
footerTableModel - the footer table model. It will be used to create a footer table below the main table. It must have the same column count as the MultiTableModel's non-header and non-footer column count.
sortable - if the tables will be sortable.

TableScrollPane

public TableScrollPane(MultiTableModel tableModel,
                       boolean sortable)
Creates a TableScrollPane without footer table. You can specify if the tables are sortable.

Parameters:
tableModel - the MultiTableModel. This is the main table model that will be used to create up to three tables in TableScrollPane.
sortable - if the tables will be sortable.

TableScrollPane

public TableScrollPane(MultiTableModel tableModel,
                       MultiTableModel footerTableModel,
                       boolean sortable,
                       boolean sync)
Creates a TableScrollPane with a footer table. You can specify if the tables are sortable.

Parameters:
tableModel - the MultiTableModel. This is the main table model that will be used to create upto three tables in TableScrollPane.
footerTableModel - the footer table model. It will be used to create a footer table below the main table. It must have the same column count as the MultiTableModel's non-header and non-footer column count.
sortable - if the tables will be sortable.
sync - if the tables will be synced. Usually you should call with sync set to true. However if you want to synchronize more tables which are not just in one TableScrollPane, you can set to false first, then call TableUtils.synchronizeTables(javax.swing.JTable[]) later.

TableScrollPane

public TableScrollPane(MultiTableModel tableModel,
                       MultiTableModel headerTableModel,
                       MultiTableModel footerTableModel,
                       boolean sortable,
                       boolean sync)
Creates a TableScrollPane with a header table and a footer table. You can specify if the tables are sortable.

Parameters:
tableModel - the MultiTableModel. This is the main table model that will be used to create up to three tables in TableScrollPane.
headerTableModel - the header table model. It will be used to create a header table below the normal table header. It must have the same column count as the MultiTableModel's non-header and non-footer column count.
footerTableModel - the footer table model. It will be used to create a footer table below the main table. It must have the same column count as the MultiTableModel's non-header and non-footer column count.
sortable - if the tables will be sortable.
sync - if the tables will be synced. Usually you should call with sync set to true. However if you want to synchronize more tables which are not just in one TableScrollPane, you can set to false first, then call TableUtils.synchronizeTables(javax.swing.JTable[]) later.

TableScrollPane

public TableScrollPane(MultiTableModel tableModel,
                       MultiTableModel footerTableModel,
                       boolean sortable,
                       int tableIndex,
                       boolean sync)
Creates a TableScrollPane with a footer table. You can specify if the tables are sortable.

Parameters:
tableModel - the MultiTableModel. This is the main table model that will be used to create up to three tables in TableScrollPane.
footerTableModel - the footer table model. It will be used to create a footer table below the main table. It must have the same column count as the MultiTableModel's non-header and non-footer column count.
sortable - if the tables will be sortable.
tableIndex - the table index of the TableScrollPane. This is only useful when using it inside a TableSplitPane.
sync - if the tables will be synced. Usually you should call with sync set to true. However if you want to synchronize more tables which are not just in one TableScrollPane, you can set to false first, then call TableUtils.synchronizeTables(javax.swing.JTable[]) later.

TableScrollPane

public TableScrollPane(MultiTableModel tableModel,
                       MultiTableModel headerTableModel,
                       MultiTableModel footerTableModel,
                       boolean sortable,
                       int tableIndex,
                       boolean sync)
Creates a TableScrollPane with a header table and a footer table. You can specify if the tables are sortable.

Parameters:
tableModel - the MultiTableModel. This is the main table model that will be used to create up to three tables in TableScrollPane.
headerTableModel - the header table model. It will be used to create a header table below the normal table header. It must have the same column count as the MultiTableModel's non-header and non-footer column count.
footerTableModel - the footer table model. It will be used to create a footer table below the main table. It must have the same column count as the MultiTableModel's non-header and non-footer column count.
sortable - if the tables will be sortable.
tableIndex - the table index of the TableScrollPane. This is only useful when using it inside a TableSplitPane.
sync - if the tables will be synced. Usually you should call with sync set to true. However if you want to synchronize more tables which are not just in one TableScrollPane, you can set to false first, then call TableUtils.synchronizeTables(javax.swing.JTable[]) later.
Method Detail

setTableModel

public void setTableModel(MultiTableModel tableModel)
Sets the original table model and recreates all child tables.

Parameters:
tableModel - the new MultiTableModel

createSortableTableModel

protected TableModel createSortableTableModel(MultiTableModel tableModel,
                                              boolean sortable)
Creates a SortableTableModel or SortableTreeTableModel for the MultiTableModel if isSortable() is true. Otherwise, tableModel itself will be returned.

See below for the default code.

 TableModel actualTableModel;
 if (tableModel instanceof TreeTableModel && sortable) {
     actualTableModel = new SortableTreeTableModel(tableModel);
 }
 else if (!(tableModel instanceof ISortableTableModel) && sortable) {
     actualTableModel = new SortableTableModel(tableModel);
 }
 else {
     actualTableModel = tableModel;
 }
 return actualTableModel;
 

Parameters:
tableModel - the MultiTableModel
sortable - true or false. If true, the tableModel should be wrapped into a SortableTableModel or SortableTreeTableModel.
Returns:
a SortableTableModel or SortableTreeTableModel for the MultiTableModel if isSortable() is true.

getTableModel

public MultiTableModel getTableModel()
Gets the original table model that is passed in constructors. It is the same as getModel().

Returns:
the original table model.

getModel

public MultiTableModel getModel()
Gets the original table model that is passed in constructors. It is the same as getTableModel().

Returns:
the original table model.

setFooterTableModel

public void setFooterTableModel(MultiTableModel footerTableModel)
Sets the footer table model.

Parameters:
footerTableModel - the footer table model

setHeaderTableModel

public void setHeaderTableModel(MultiTableModel headerTableModel)
Sets the header table model.

Parameters:
headerTableModel - the header table model
Since:
3.2.3

getFooterTableModel

public MultiTableModel getFooterTableModel()

isSortable

public boolean isSortable()

setSortable

public void setSortable(boolean sortable)

customizeTable

protected void customizeTable(JTable table)
Customizes the table created by TableScrollPane. All tables has client property setup to identify. You can call getClientProperty(TABLE_KEY) to find what table it is. The values are defined as MAIN_TABLE, ROWHEADER_TABLE, ROWFOOTER_TABLE, COLUMNFOOTER_TABLE, ROWHEADER_COLUMNFOOTER_TABLE, and ROWFOOTER_COLUMNFOOTER_TABLE.

Parameters:
table - the child table

getMainTable

public JTable getMainTable()
The main table. This is a table created from MultiTableModel's non-header and non-footer columns.

Returns:
the main table.

getRowHeaderTable

public JTable getRowHeaderTable()
The row header table. This is a table created from MultiTableModel's header columns.

Returns:
the row header table.

getRowFooterTable

public JTable getRowFooterTable()
The row footer table. This is a table created from MultiTableModel's footer columns.

Returns:
the row footer table.

getColumnFooterTable

public JTable getColumnFooterTable()
The column footer table. This is a table created from footerTableModel, the second parameter of TableScrollPane's constructor.

Returns:
the column footer table.

getRowHeaderColumnFooterTable

public JTable getRowHeaderColumnFooterTable()
Gets the row header of the column footer table.

Returns:
the row header of column footer table.

getRowFooterColumnFooterTable

public JTable getRowFooterColumnFooterTable()
Gets the row footer of the column footer table.

Returns:
the row header of column footer table.

getColumnHeaderTable

public JTable getColumnHeaderTable()

getRowHeaderColumnHeaderTable

public JTable getRowHeaderColumnHeaderTable()

getRowFooterColumnHeaderTable

public JTable getRowFooterColumnHeaderTable()

createTable

@Deprecated
protected JTable createTable(TableModel model,
                                        boolean sortable,
                                        int type,
                                        int tableIndex)
Deprecated. We added a footer parameter to the createTable method. This method was left here for backward compatible reason. Please change your code to override createTable(javax.swing.table.TableModel, boolean, int) instead.

Parameters:
model - the table model
sortable - if the table is sortable
type - the table type
tableIndex - the table index
Returns:
the created table.

createTable

protected JTable createTable(TableModel model,
                             boolean sortable,
                             int type,
                             boolean columnFooter,
                             int tableIndex)
Creates the table. TableScrollPane will use this method to create all table instances.

Please be noted that it is highly NOT recommended to override this method although you could do that. The reason is that we did some client property registrations and some default setting here. So if you override this method without taking care of that part, you will find the behavior of your new TableScrollPane is not as you are actually expecting.

If you want to create an instance with different table class, please try override createTable(javax.swing.table.TableModel, boolean, int) or createTable(javax.swing.table.TableModel, boolean). If you will create different table classes for header table and main table, you would have to override the first one, which has type as one of its three parameters. If you will create the same table class for every table in your TableScrollPane, you could just override the second one with only two parameters.

If you want to configure the tables which ares already created, please override getTableCustomizer() to create your own table customizer. You can refer our TableScrollPaneDemo for the details.

Below is the default client property registrations and settings in this method. If you decided to override this one, please also consider add those lines in.


 String tableKey = null;
 switch (type) {
     case MultiTableModel.REGULAR_COLUMN:
         tableKey = columnFooter ? COLUMNFOOTER_TABLE : MAIN_TABLE;
         break;
     case MultiTableModel.HEADER_COLUMN:
        tableKey = columnFooter ? ROWHEADER_COLUMNFOOTER_TABLE : ROWHEADER_TABLE;
         break;
     case MultiTableModel.FOOTER_COLUMN:
         tableKey = columnFooter ? ROWFOOTER_COLUMNFOOTER_TABLE : ROWFOOTER_TABLE;
         break;
 }
 table.putClientProperty(TABLE_KEY, tableKey);
 table.putClientProperty(TableSplitPane.TABLE_INDEX, tableIndex);
 table.putClientProperty(TABLESCROLLPANE_KEY, this);
 table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
 if (table instanceof SortableTable) {
     ((SortableTable) table).setSortable(sortable);
 }
 return table;
 

Parameters:
model - the table model.
sortable - if the table is sortable.
type - the valid values are MultiTableModel.REGULAR_COLUMN, MultiTableModel.HEADER_COLUMN and MultiTableModel.FOOTER_COLUMN
columnFooter - true if the table is for a column footer. Otherwise false.
tableIndex - the index of the table. THe value is returned from MultiTableModel.getTableIndex(int) method.
Returns:
the table.

createTable

protected JTable createTable(TableModel model,
                             boolean sortable,
                             int type)
Creates the table. Please consider override this method if you want to have your other tables implementing more than just SortableTable. However, if you just want to configure the table it creates, please consider override getTableCustomizer().

The default implementation of this method is like below:

 return createTable(model, sortable);
 

As you can see at that method, it will return a SortableTable by default. If you want to use another table such as TreeTable, you can override this method and use parameters type and table Index to determine it is row header table, then return a TreeTable instead.

Parameters:
model - the table model
sortable - true or false.
type - the valid values are MultiTableModel.REGULAR_COLUMN, MultiTableModel.HEADER_COLUMN and MultiTableModel.FOOTER_COLUMN
Returns:
a table.

createTable

protected JTable createTable(TableModel model,
                             boolean sortable)
Creates the table. You can override this method or createTable(javax.swing.table.TableModel, boolean, int, boolean, int) if you just want to configure the table with no intention to create your own table.

The default implementation is like below:

 return new SortableTable(model);
 

As you can see, it will return a SortableTable by default.

Parameters:
model - the table model
sortable - true or false.
Returns:
a table.

isEditing

public boolean isEditing()

getEditingTable

public JTable getEditingTable()

getAllChildTables

public JTable[] getAllChildTables()
Gets all child tables in an array. The order is getMainTable(), getRowHeaderTable(), getRowFooterTable(), getColumnFooterTable(), getRowHeaderColumnFooterTable, and getRowFooterColumnFooterTable. To tell which table is which, you can use table.getClientProperty(TableScrollPane.TABLE_KEY) which will tell you the type of the table. For example, if it returns TableScrollPane.MAIN_TABLE, it means the table is the main table.

Returns:
an array of all child tables.

getCellEditor

public TableCellEditor getCellEditor()

removeExtraColumns

protected void removeExtraColumns(JTable table,
                                  int type,
                                  int tableIndex)
Removes extra columns from TableColumnModel that doesn't match with the type and tableIndex.

Parameters:
table - the table
type - the table type such as REGULAR_COLUMN, FOOTER_COLUMN or HEADER_COLUMN.
tableIndex - the table index

refreshColumns

public void refreshColumns()
Calls this method when getColumnType value changed in MultiTableModel.


resizeRowHeaderTableToFit

public void resizeRowHeaderTableToFit()
Resizes the row header table to fix the gap between the main table, if any.


getTableCustomizer

public TableCustomizer getTableCustomizer()
Gets the table customizer. It will use when create the tables used by this TableScrollPane.

Returns:
the table customizer.

setTableCustomizer

public void setTableCustomizer(TableCustomizer tableCustomizer)
Sets the table customizer. It will use when create the tables used by this TableScrollPane.

Parameters:
tableCustomizer - the new table customizer.

setRowSelectionAllowed

public void setRowSelectionAllowed(boolean rowSelectionAllowed)
Sets whether the rows in this model can be selected.

Specified by:
setRowSelectionAllowed in interface TableAdapter
Parameters:
rowSelectionAllowed - true if this model will allow row selection
See Also:
getRowSelectionAllowed()

getRowSelectionAllowed

public boolean getRowSelectionAllowed()
Returns true if rows can be selected.

Specified by:
getRowSelectionAllowed in interface TableAdapter
Returns:
true if rows can be selected, otherwise false
See Also:
setRowSelectionAllowed(boolean)

setColumnSelectionAllowed

public void setColumnSelectionAllowed(boolean columnSelectionAllowed)
Sets whether the columns in this model can be selected.

Specified by:
setColumnSelectionAllowed in interface TableAdapter
Parameters:
columnSelectionAllowed - true if this model will allow column selection
See Also:
getColumnSelectionAllowed()

getColumnSelectionAllowed

public boolean getColumnSelectionAllowed()
Returns true if columns can be selected.

Specified by:
getColumnSelectionAllowed in interface TableAdapter
Returns:
true if columns can be selected, otherwise false
See Also:
setColumnSelectionAllowed(boolean)

setCellSelectionEnabled

public void setCellSelectionEnabled(boolean cellSelectionEnabled)
Sets whether this table allows both a column selection and a row selection to exist simultaneously. When set, the table treats the intersection of the row and column selection models as the selected cells. Override isCellSelected to change this default behavior. This method is equivalent to setting both the rowSelectionAllowed property and columnSelectionAllowed property of the columnModel to the supplied value.

Specified by:
setCellSelectionEnabled in interface TableAdapter
Parameters:
cellSelectionEnabled - true if simultaneous row and column selection is allowed
See Also:
getCellSelectionEnabled()

getCellSelectionEnabled

public boolean getCellSelectionEnabled()
Returns true if both row and column selection models are enabled. Equivalent to getRowSelectionAllowed() && getColumnSelectionAllowed().

Specified by:
getCellSelectionEnabled in interface TableAdapter
Returns:
true if both row and column selection models are enabled
See Also:
setCellSelectionEnabled(boolean)

setNonContiguousCellSelectionAllowed

public void setNonContiguousCellSelectionAllowed(boolean nonContiguousCellSelectionAllowed)
Sets whether non-contiguous cell selection in this model can be selected. Please note, non-contiguous cell selection is a feature in JideTable so you have to use JideTable or its subclasses in order to use this option. Also please note, due to limitation of TableScrollPane, only one table can be selected at a time. In the other words, you can't select a few cells in header table and a few cells in the main table.

Parameters:
nonContiguousCellSelectionAllowed - true if this model will allow non-contiguous cell selection
See Also:
isNonContiguousCellSelectionAllowed()

isNonContiguousCellSelectionAllowed

public boolean isNonContiguousCellSelectionAllowed()
Returns true if non-contiguous cell selection can be selected.

Returns:
true if -contiguous cell selection is enabled, otherwise false
See Also:
setNonContiguousCellSelectionAllowed(boolean)

resynchronizeTablesSelection

protected void resynchronizeTablesSelection()

getRowCount

public int getRowCount()
Gets the total row count of TableScrollPane.

Specified by:
getRowCount in interface TableAdapter
Returns:
the total row count of TableScrollPane.

getColumnCount

public int getColumnCount()
Gets the total column count of TableScrollPane.

Specified by:
getColumnCount in interface TableAdapter
Returns:
the total column count of TableScrollPane.

isAllowMultiSelectionInDifferentTable

public boolean isAllowMultiSelectionInDifferentTable()
Get the flag indicating if the TableScrollPane allow select multiple rows in different tables, including main table and column footer table for example.

The default setting is false, which means that if you select one row in main table, the current selection in column footer table will be automatically cleared. You can set this flag to true if you don't like this behavior.

Returns:
the flag

setAllowMultiSelectionInDifferentTable

public void setAllowMultiSelectionInDifferentTable(boolean allowMultiSelectionInDifferentTable)
Set the flag indicating if the TableScrollPane allow select multiple rows in different tables, including main table and column footer table for example.

Parameters:
allowMultiSelectionInDifferentTable - true if allow multiple selection. Otherwise false.

getTableAtColumn

public TableScrollPane.TablePosition getTableAtColumn(int column)
Gets the table as the specified column index.

Parameters:
column - the column index related to TableScrollPane.
Returns:
a TablePosition. The table field in TablePosition is the child table and the column field is the converted column index relative to the child table. The row field is always -1. Because the row index is not specified, the table could only be the main table, the row header table or the row footer table. It will never be one of the column footer tables.

getTableAtRow

public TableScrollPane.TablePosition getTableAtRow(int row)
Gets the table as the specified row index.

Parameters:
row - the row index related to TableScrollPane.
Returns:
a TablePosition. The table field in TablePosition is the child table and the row field is the converted row index relative to the child table. The column field is always -1. Because the column index is not specified, the table could only be the main table or the column footer table. It will never be the row header tables or the row footer table.

getTableAtCell

public TableScrollPane.TablePosition getTableAtCell(int row,
                                                    int column)
Gets the table as the specified row and column index.

Parameters:
row - the row index related to TableScrollPane.
column - the column index related to TableScrollPane.
Returns:
a TablePosition. The table field in TablePosition is the child table, the column field is the converted column index relative to the child table and the row field is the converted row index relative to the child table.

getColumnName

public String getColumnName(int column)
Returns the name of the column appearing in the view at column position column.

Specified by:
getColumnName in interface TableAdapter
Parameters:
column - the column in the view being queried
Returns:
the name of the column at position column in the view where the first column is column 0

getColumnClass

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

Specified by:
getColumnClass in interface TableAdapter
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

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.

Specified by:
getValueAt in interface TableAdapter
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

setValueAt

public void setValueAt(Object aValue,
                       int row,
                       int column)
Sets the value for the cell in the table model 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.

aValue is the new value.

Specified by:
setValueAt in interface TableAdapter
Parameters:
aValue - the new value
row - the row of the cell to be changed
column - the column of the cell to be changed
See Also:
getValueAt(int, int)

isCellEditable

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

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

Specified by:
isCellEditable in interface TableAdapter
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:
setValueAt(Object, int, int)

getSelectedRow

public int getSelectedRow()
Returns the index of the first selected row, -1 if no row is selected.

Specified by:
getSelectedRow in interface TableAdapter
Returns:
the index of the first selected row

getSelectedColumn

public int getSelectedColumn()
Returns the index of the first selected column, -1 if no column is selected.

Specified by:
getSelectedColumn in interface TableAdapter
Returns:
the index of the first selected column

getSelectedRows

public int[] getSelectedRows()
Returns the indices of all selected rows.

Specified by:
getSelectedRows in interface TableAdapter
Returns:
an array of integers containing the indices of all selected rows, or an empty array if no row is selected
See Also:
getSelectedRow()

convertColumnIndexToView

public int convertColumnIndexToView(int modelIndex)
Convert the view column index in the entire TableScrollPane to model index.

Parameters:
modelIndex - the model column index
Returns:
the view index

convertColumnIndexToModel

public int convertColumnIndexToModel(int viewIndex)
Convert the view column index in the entire TableScrollPane to model index.

Parameters:
viewIndex - the view column index counting from 0 including row header table, main table and row footer table
Returns:
the model index.

getSelectedColumns

public int[] getSelectedColumns()
Returns the indices of all selected columns.

Specified by:
getSelectedColumns in interface TableAdapter
Returns:
an array of integers containing the indices of all selected columns, or an empty array if no column is selected
See Also:
getSelectedColumn()

getSelectedRowCount

public int getSelectedRowCount()
Returns the number of selected rows.

Specified by:
getSelectedRowCount in interface TableAdapter
Returns:
the number of selected rows, 0 if no rows are selected

getSelectedColumnCount

public int getSelectedColumnCount()
Returns the number of selected columns.

Specified by:
getSelectedColumnCount in interface TableAdapter
Returns:
the number of selected columns, 0 if no columns are selected

isRowSelected

public boolean isRowSelected(int row)
Returns true if the specified index is in the valid range of rows, and the row at that index is selected.

Specified by:
isRowSelected in interface TableAdapter
Parameters:
row - the row index
Returns:
true if row is a valid index and the row at that index is selected (where 0 is the first row)

isColumnSelected

public boolean isColumnSelected(int column)
Returns true if the specified index is in the valid range of columns, and the column at that index is selected.

Specified by:
isColumnSelected in interface TableAdapter
Parameters:
column - the column in the column model
Returns:
true if column is a valid index and the column at that index is selected (where 0 is the first column)

isCellSelected

public boolean isCellSelected(int row,
                              int column)
Returns true if the specified indices are in the valid range of rows and columns and the cell at the specified position is selected.

Specified by:
isCellSelected in interface TableAdapter
Parameters:
row - the row being queried
column - the column being queried
Returns:
true if row and column are valid indices and the cell at index (row, column) is selected, where the first row and first column are at index 0

clearSelection

public void clearSelection()
Deselects all selected columns and rows.


changeSelection

public void changeSelection(int rowIndex,
                            int columnIndex,
                            boolean toggle,
                            boolean extend)
Description copied from interface: TableAdapter
Updates the selection models of the table, depending on the state of the two flags: toggle and extend. Most changes to the selection that are the result of keyboard or mouse events received by the UI are channeled through this method so that the behavior may be overridden by a subclass. Some UIs may need more functionality than this method provides, such as when manipulating the lead for discontiguous selection, and may not call into this method for some selection changes.

This implementation uses the following conventions:

Specified by:
changeSelection in interface TableAdapter
Parameters:
rowIndex - affects the selection at row
columnIndex - affects the selection at column
toggle - see description above
extend - if true, extend the current selection

print

public boolean print()
              throws PrinterException
A convenience method that displays a printing dialog, and then prints this JTable in mode PrintMode.FIT_WIDTH, with no header or footer text. A modal progress dialog, with an abort option, will be shown for the duration of printing.

Note: In headless mode, no dialogs are shown and printing occurs on the default printer.

Returns:
true, unless printing is cancelled by the user
Throws:
SecurityException - if this thread is not allowed to initiate a print job request
PrinterException - if an error in the print system causes the job to be aborted
Since:
3.3.0
See Also:
print(javax.swing.JTable.PrintMode, java.text.MessageFormat, java.text.MessageFormat, boolean, javax.print.attribute.PrintRequestAttributeSet, boolean, javax.print.PrintService), getPrintable(javax.swing.JTable.PrintMode, java.text.MessageFormat, java.text.MessageFormat)

print

public boolean print(JTable.PrintMode printMode)
              throws PrinterException
A convenience method that displays a printing dialog, and then prints this JTable in the given printing mode, with no header or footer text. A modal progress dialog, with an abort option, will be shown for the duration of printing.

Note: In headless mode, no dialogs are shown and printing occurs on the default printer.

Parameters:
printMode - the printing mode that the printable should use
Returns:
true, unless printing is cancelled by the user
Throws:
SecurityException - if this thread is not allowed to initiate a print job request
PrinterException - if an error in the print system causes the job to be aborted
Since:
3.3.0
See Also:
print(javax.swing.JTable.PrintMode, java.text.MessageFormat, java.text.MessageFormat, boolean, javax.print.attribute.PrintRequestAttributeSet, boolean, javax.print.PrintService), getPrintable(javax.swing.JTable.PrintMode, java.text.MessageFormat, java.text.MessageFormat)

print

public boolean print(JTable.PrintMode printMode,
                     MessageFormat headerFormat,
                     MessageFormat footerFormat)
              throws PrinterException
A convenience method that displays a printing dialog, and then prints this JTable in the given printing mode, with the specified header and footer text. A modal progress dialog, with an abort option, will be shown for the duration of printing.

Note: In headless mode, no dialogs are shown and printing occurs on the default printer.

Parameters:
printMode - the printing mode that the printable should use
headerFormat - a MessageFormat specifying the text to be used in printing a header, or null for none
footerFormat - a MessageFormat specifying the text to be used in printing a footer, or null for none
Returns:
true, unless printing is cancelled by the user
Throws:
SecurityException - if this thread is not allowed to initiate a print job request
PrinterException - if an error in the print system causes the job to be aborted
Since:
3.3.0
See Also:
print(javax.swing.JTable.PrintMode, java.text.MessageFormat, java.text.MessageFormat, boolean, javax.print.attribute.PrintRequestAttributeSet, boolean, javax.print.PrintService), getPrintable(javax.swing.JTable.PrintMode, java.text.MessageFormat, java.text.MessageFormat)

print

public boolean print(JTable.PrintMode printMode,
                     MessageFormat headerFormat,
                     MessageFormat footerFormat,
                     boolean showPrintDialog,
                     PrintRequestAttributeSet attr,
                     boolean interactive)
              throws PrinterException,
                     HeadlessException
Prints this table with the default printer specified as the print service.

Parameters:
printMode - the printing mode that the printable should use
headerFormat - a MessageFormat specifying the text to be used in printing a header, or null for none
footerFormat - a MessageFormat specifying the text to be used in printing a footer, or null for none
showPrintDialog - whether or not to display a print dialog
attr - a PrintRequestAttributeSet specifying any printing attributes, or null for none
interactive - whether or not to print in an interactive mode
Returns:
true, unless printing is cancelled by the user
Throws:
HeadlessException - if the method is asked to show a printing dialog or run interactively, and GraphicsEnvironment.isHeadless returns true
SecurityException - if this thread is not allowed to initiate a print job request
PrinterException - if an error in the print system causes the job to be aborted
Since:
3.3.0
See Also:
print(javax.swing.JTable.PrintMode, java.text.MessageFormat, java.text.MessageFormat, boolean, javax.print.attribute.PrintRequestAttributeSet, boolean, javax.print.PrintService), getPrintable(javax.swing.JTable.PrintMode, java.text.MessageFormat, java.text.MessageFormat)

print

public boolean print(JTable.PrintMode printMode,
                     MessageFormat headerFormat,
                     MessageFormat footerFormat,
                     boolean showPrintDialog,
                     PrintRequestAttributeSet attr,
                     boolean interactive,
                     PrintService service)
              throws PrinterException,
                     HeadlessException
Prints this JTable. Takes steps that the majority of developers would take in order to print a JTable. In short, it prepares the table, calls getPrintable to fetch an appropriate Printable, and then sends it to the printer.

A boolean parameter allows you to specify whether or not a printing dialog is displayed to the user. When it is, the user may use the dialog to change the destination printer or printing attributes, or even to cancel the print. Another two parameters allow for a PrintService and printing attributes to be specified. These parameters can be used either to provide initial values for the print dialog, or to specify values when the dialog is not shown.

A second boolean parameter allows you to specify whether or not to perform printing in an interactive mode. If true, a modal progress dialog, with an abort option, is displayed for the duration of printing . This dialog also prevents any user action which may affect the table. However, it can not prevent the table from being modified by code (for example, another thread that posts updates using SwingUtilities.invokeLater). It is therefore the responsibility of the developer to ensure that no other code modifies the table in any way during printing (invalid modifications include changes in: size, renderers, or underlying data). Printing behavior is undefined when the table is changed during printing.

If false is specified for this parameter, no dialog will be displayed and printing will begin immediately on the event-dispatch thread. This blocks any other events, including repaints, from being processed until printing is complete. Although this effectively prevents the table from being changed, it doesn't provide a good user experience. For this reason, specifying false is only recommended when printing from an application with no visible GUI.

Note: Attempting to show the printing dialog or run interactively, while in headless mode, will result in a HeadlessException.

Before fetching the printable, this method will gracefully terminate editing, if necessary, to prevent an editor from showing in the printed result. Additionally, JTable will prepare its renderers during printing such that selection and focus are not indicated. As far as customizing further how the table looks in the printout, developers can provide custom renderers or paint code that conditionalize on the value of JComponent.isPaintingForPrint().

See getPrintable(javax.swing.JTable.PrintMode, java.text.MessageFormat, java.text.MessageFormat) for more description on how the table is printed.

Parameters:
printMode - the printing mode that the printable should use
headerFormat - a MessageFormat specifying the text to be used in printing a header, or null for none
footerFormat - a MessageFormat specifying the text to be used in printing a footer, or null for none
showPrintDialog - whether or not to display a print dialog
attr - a PrintRequestAttributeSet specifying any printing attributes, or null for none
interactive - whether or not to print in an interactive mode
service - the destination PrintService, or null to use the default printer
Returns:
true, unless printing is cancelled by the user
Throws:
HeadlessException - if the method is asked to show a printing dialog or run interactively, and GraphicsEnvironment.isHeadless returns true
SecurityException - if a security manager exists and its SecurityManager.checkPrintJobAccess() method disallows this thread from creating a print job request
PrinterException - if an error in the print system causes the job to be aborted
Since:
3.3.0
See Also:
getPrintable(javax.swing.JTable.PrintMode, java.text.MessageFormat, java.text.MessageFormat)

getPrintable

public Printable getPrintable(JTable.PrintMode printMode,
                              MessageFormat headerFormat,
                              MessageFormat footerFormat)
Return a Printable for use in printing this JTable.

This method is meant for those wishing to customize the default Printable implementation used by JTable's print methods. Developers wanting simply to print the table should use one of those methods directly.

The Printable can be requested in one of two printing modes. In both modes, it spreads table rows naturally in sequence across multiple pages, fitting as many rows as possible per page. PrintMode.NORMAL specifies that the table be printed at its current size. In this mode, there may be a need to spread columns across pages in a similar manner to that of the rows. When the need arises, columns are distributed in an order consistent with the table's ComponentOrientation. PrintMode.FIT_WIDTH specifies that the output be scaled smaller, if necessary, to fit the table's entire width (and thereby all columns) on each page. Width and height are scaled equally, maintaining the aspect ratio of the output.

The Printable heads the portion of table on each page with the appropriate section from the table's JTableHeader, if it has one.

Header and footer text can be added to the output by providing MessageFormat arguments. The printing code requests Strings from the formats, providing a single item which may be included in the formatted string: an Integer representing the current page number.

You are encouraged to read the documentation for MessageFormat as some characters, such as single-quote, are special and need to be escaped.

Here's an example of creating a MessageFormat that can be used to print "Duke's Table: Page - " and the current page number:

     // notice the escaping of the single quote
     // notice how the page number is included with "{0}"
     MessageFormat format = new MessageFormat("Duke''s Table: Page - {0}");
 

The Printable constrains what it draws to the printable area of each page that it prints. Under certain circumstances, it may find it impossible to fit all of a page's content into that area. In these cases the output may be clipped, but the implementation makes an effort to do something reasonable. Here are a few situations where this is known to occur, and how they may be handled by this particular implementation:

It is entirely valid for this Printable to be wrapped inside another in order to create complex reports and documents. You may even request that different pages be rendered into different sized printable areas. The implementation must be prepared to handle this (possibly by doing its layout calculations on the fly). However, providing different heights to each page will likely not work well with PrintMode.NORMAL when it has to spread columns across pages.

As far as customizing how the table looks in the printed result, JTable itself will take care of hiding the selection and focus during printing. For additional customizations, your renderers or painting code can customize the look based on the value of JComponent.isPaintingForPrint()

Also, before calling this method you may wish to first modify the state of the table, such as to cancel cell editing or have the user size the table appropriately. However, you must not modify the state of the table after this Printable has been fetched (invalid modifications include changes in size or underlying data). The behavior of the returned Printable is undefined once the table has been changed.

Parameters:
printMode - the printing mode that the printable should use
headerFormat - a MessageFormat specifying the text to be used in printing a header, or null for none
footerFormat - a MessageFormat specifying the text to be used in printing a footer, or null for none
Returns:
a Printable for printing this JTable
Since:
3.3.0
See Also:
print(javax.swing.JTable.PrintMode, java.text.MessageFormat, java.text.MessageFormat, boolean, javax.print.attribute.PrintRequestAttributeSet, boolean, javax.print.PrintService), Printable, PrinterJob

JIDE 3.5.15