Class PFCTable
- All Implemented Interfaces:
ImageObserver,MenuContainer,Serializable,EventListener,Accessible,CellEditorListener,ListSelectionListener,RowSorterListener,TableColumnModelListener,TableModelListener,Scrollable
Usage: To create a PFCTable which defines all columns to be sortable, use the following methods:
public PFCTable(TableModel model)
public PFCTable(int numRows, int numColumns)
public PFCTable(Vector rowData, Vector columnNames)
public PFCTable(final Object[][] rowData, final Object[] columnNames)
To create a PFCTable which is not sortable, use the following methods, where sortable is set to
false
public PFCTable(TableModel model, boolean sortable)
public PFCTable(int numRows, int numColumns, boolean sortable)
public PFCTable(Vector rowData, Vector columnNames, boolean sortable)
public PFCTable(final Object[][] rowData, final Object[] columnNames, boolean sortable)
To create a PFCTable with no data model, use the following method:
public PFCTable()
You can then later add a data model, and make the table sortable by default, by calling the following method:
setModel(TableModel) or make the table not sortable by calling the
following method:
setModel(TableModel, boolean sortable) where sortable specified
set to false
You can also set all columns to be sortable, by calling the following method:
setSortable(true)
To set an individual column to be sortable, do the following:
setColumnSortable(columnIndex) where columnIndex
is the index of the column you wish to make sortable.
To set a column to be sorted alpha-numerically, do the following:
table.setAlphaNumericColumn(columnIndex) where columnIndex
is the index of the column you wish to sort alpha-numerically.
There is a test program, called TestTable, which can be used for examples
on how to setup various combinations of tables used for sorting.
- Author:
- Les Thomas
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JTable
JTable.AccessibleJTable, JTable.DropLocation, JTable.PrintModeNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
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, tableHeaderFields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
ConstructorsConstructorDescriptionPFCTable()Constructs a defaultPFCTablethat is initialized with a default data model, a default column model, and a default selection model.PFCTable(int numRows, int numColumns) Convenience method that constructs aPFCTablewithnumRowsandnumColumnsof empty cells usingDefaultTableModel.PFCTable(int numRows, int numColumns, boolean sortable) Convenience method that constructs aPFCTablewithnumRowsandnumColumnsof empty cells usingDefaultTableModel.Convenience method that constructs aPFCTableto display the values in the two dimensional array,rowData, with column names,columnNames.Convenience method that constructs aPFCTableto display the values in the two dimensional array,rowData, with column names,columnNames.Convenience method that constructs aPFCTableto display the values in theVectorofVectors,rowData, with column names,columnNames.Constructs aPFCTableto display the values in theVectorofVectors,rowData, with column names,columnNames.PFCTable(TableModel model) Convenience method that constructs a defaultPFCTablethat is initialized with a TableModel model, and by default sets all columns to be sortable.PFCTable(TableModel model, boolean sortable) Convenience method that constructs a defaultPFCTablethat is initialized with a DefaultTableModel model, and by default sets all columns to either be sortable or not, based upon the specified sortable value. -
Method Summary
Modifier and TypeMethodDescriptionbooleanisColumnSortable(int columnIndex) Returns whether specified column in the table is sortable.booleanReturns whether all columns in the table are sortable.voidsetAlphaNumericColumn(int columnIndex) Set the specified column, referenced by columnIndex to be an alpha numeric column.voidsetModel(TableModel newModel) Sets the data model for this table tonewModeland registers with it for listener notifications from the new data model.voidsetModel(TableModel newModel, boolean sortable) Sets the data model for this table tonewModeland registers with it for listener notifications from the new data model.voidsetSortable(boolean sortable) Sets all the columns in the table to be sortable.voidsetSortableColumn(int columnIndex) Sets the specified column, referenced by columnIndex to be sortable.voidsetSortableColumn(int columnIndex, boolean sortable) Sets the specified column, referenced by columnIndex to be either be sortable or not, based upon the specified sortable value.voidsetSortableColumns(ArrayList columnList) Sets the specified columns, contained in the columnList ArrayList to be sortable.Methods inherited from class javax.swing.JTable
addColumn, addColumnSelectionInterval, addNotify, addRowSelectionInterval, changeSelection, clearSelection, columnAdded, columnAtPoint, columnMarginChanged, columnMoved, columnRemoved, columnSelectionChanged, configureEnclosingScrollPane, convertColumnIndexToModel, convertColumnIndexToView, convertRowIndexToModel, convertRowIndexToView, createDefaultColumnModel, createDefaultColumnsFromModel, createDefaultDataModel, createDefaultEditors, createDefaultRenderers, createDefaultSelectionModel, createDefaultTableHeader, createScrollPaneForTable, doLayout, editCellAt, editCellAt, editingCanceled, editingStopped, getAccessibleContext, getAutoCreateColumnsFromModel, getAutoCreateRowSorter, getAutoResizeMode, getCellEditor, getCellEditor, getCellRect, getCellRenderer, getCellSelectionEnabled, getColumn, getColumnClass, getColumnCount, getColumnModel, getColumnName, getColumnSelectionAllowed, getDefaultEditor, getDefaultRenderer, getDragEnabled, getDropLocation, getDropMode, getEditingColumn, getEditingRow, getEditorComponent, getFillsViewportHeight, getGridColor, getIntercellSpacing, getModel, getPreferredScrollableViewportSize, getPrintable, getRowCount, getRowHeight, getRowHeight, getRowMargin, getRowSelectionAllowed, getRowSorter, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedColumn, getSelectedColumnCount, getSelectedColumns, getSelectedRow, getSelectedRowCount, getSelectedRows, getSelectionBackground, getSelectionForeground, getSelectionModel, getShowHorizontalLines, getShowVerticalLines, getSurrendersFocusOnKeystroke, getTableHeader, getToolTipText, getUI, getUIClassID, getUpdateSelectionOnSort, getValueAt, initializeLocalVars, isCellEditable, isCellSelected, isColumnSelected, isEditing, isRowSelected, moveColumn, paramString, prepareEditor, prepareRenderer, print, print, print, print, print, processKeyBinding, removeColumn, removeColumnSelectionInterval, removeEditor, removeNotify, removeRowSelectionInterval, resizeAndRepaint, rowAtPoint, selectAll, setAutoCreateColumnsFromModel, setAutoCreateRowSorter, setAutoResizeMode, setCellEditor, setCellSelectionEnabled, setColumnModel, setColumnSelectionAllowed, setColumnSelectionInterval, setDefaultEditor, setDefaultRenderer, setDragEnabled, setDropMode, setEditingColumn, setEditingRow, setFillsViewportHeight, setGridColor, setIntercellSpacing, setPreferredScrollableViewportSize, setRowHeight, setRowHeight, setRowMargin, setRowSelectionAllowed, setRowSelectionInterval, setRowSorter, setSelectionBackground, setSelectionForeground, setSelectionMode, setSelectionModel, setShowGrid, setShowHorizontalLines, setShowVerticalLines, setSurrendersFocusOnKeystroke, setTableHeader, setUI, setUpdateSelectionOnSort, setValueAt, sizeColumnsToFit, sizeColumnsToFit, sorterChanged, tableChanged, unconfigureEnclosingScrollPane, updateUI, valueChangedMethods inherited from class javax.swing.JComponent
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateMethods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeMethods 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Constructor Details
-
PFCTable
public PFCTable()Constructs a defaultPFCTablethat is initialized with a default data model, a default column model, and a default selection model. To set a TableModel, callsetModel(TableModel model)which will set the table to be sortable by default orsetTableModel(TableModel model, boolean sortable), which will set the table to be sortable, based upon specified sortable value.- See Also:
-
PFCTable
Convenience method that constructs a defaultPFCTablethat is initialized with a TableModel model, and by default sets all columns to be sortable. To construct a defaultPFCTablethat is not sortable, usePFCTable(TableModel model, boolean sortable)with sortable set to false.- Parameters:
model- the data model for the table.
-
PFCTable
Convenience method that constructs a defaultPFCTablethat is initialized with a DefaultTableModel model, and by default sets all columns to either be sortable or not, based upon the specified sortable value.- Parameters:
model- the data model for the table.sortable- true (sortable), false (not sortable).
-
PFCTable
public PFCTable(int numRows, int numColumns) Convenience method that constructs aPFCTablewithnumRowsandnumColumnsof empty cells usingDefaultTableModel. By default, all columns will be set to be sortable. To set the columns to not be sortable, usePFCTable(int numRows, int numColumns, boolean sortable)with sortable set to false. The columns will have names of the form "A", "B", "C", etc.- Parameters:
numRows- the number of rows the table holdsnumColumns- the number of columns the table holds- See Also:
-
PFCTable
public PFCTable(int numRows, int numColumns, boolean sortable) Convenience method that constructs aPFCTablewithnumRowsandnumColumnsof empty cells usingDefaultTableModel. Columns will be set to be either be sortable or not, based upon the sortable value. The columns will have names of the form "A", "B", "C", etc.- Parameters:
numRows- the number of rows the table holdsnumColumns- the number of columns the table holdssortable- true (sortable), false (not sortable).- See Also:
-
PFCTable
Convenience method that constructs aPFCTableto display the values in theVectorofVectors,rowData, with column names,columnNames. TheVectorscontained inrowDatashould 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);
By default, all columns will be set to be sortable. To set the columns to not be sortable, use
PFCTable(Vector rowData, Vector columnNames, boolean sortable)with sortable set to false.- Parameters:
rowData- the data for the new tablecolumnNames- names of each column
-
PFCTable
Constructs aPFCTableto display the values in theVectorofVectors,rowData, with column names,columnNames. TheVectorscontained inrowDatashould 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);
- Parameters:
rowData- the data for the new tablecolumnNames- names of each columnsortable- true (sortable), false (not sortable).
-
PFCTable
Convenience method that constructs aPFCTableto display the values in the two dimensional array,rowData, with column names,columnNames.rowDatais 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.By default, all columns will be set to be sortable. To set the columns to not be sortable, use
PFCTable(final Object[][] rowData, final Object[] columnNames, boolean sortable)with sortable set to false.- Parameters:
rowData- the data for the new tablecolumnNames- names of each column
-
PFCTable
Convenience method that constructs aPFCTableto display the values in the two dimensional array,rowData, with column names,columnNames.rowDatais 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.Columns will be set to be either be sortable or not, based upon the sortable value.
- Parameters:
rowData- the data for the new tablecolumnNames- names of each columnsortable- true (sortable), false (not sortable)
-
-
Method Details
-
setModel
Sets the data model for this table tonewModeland registers with it for listener notifications from the new data model. Previous listeners will be removed.- Parameters:
newModel- the new data source for this tablesortable- true (sortable), false (not sortable)
-
setModel
Sets the data model for this table tonewModeland registers with it for listener notifications from the new data model. Previous listeners will be removed. By default, the table will be sortable. -
setSortable
public void setSortable(boolean sortable) Sets all the columns in the table to be sortable.- Parameters:
sortable- true (sortable), false (not sortable).
-
isTableSortable
public boolean isTableSortable()Returns whether all columns in the table are sortable.- Returns:
- true (sortable), false otherwise.
-
isColumnSortable
public boolean isColumnSortable(int columnIndex) Returns whether specified column in the table is sortable.- Parameters:
columnIndex- index of the column to set- Returns:
- true (sortable), false if column is not sortable, or columnIndex is invalid.
-
setSortableColumn
public void setSortableColumn(int columnIndex) Sets the specified column, referenced by columnIndex to be sortable.- Parameters:
columnIndex- int indicating the column index of the column to be sortable.columnIndex- index of the column to set
-
setSortableColumn
public void setSortableColumn(int columnIndex, boolean sortable) Sets the specified column, referenced by columnIndex to be either be sortable or not, based upon the specified sortable value.- Parameters:
columnIndex- index of the column to setsortable- true (sortable), false (not sortable)
-
setSortableColumns
Sets the specified columns, contained in the columnList ArrayList to be sortable. Note: ArrayList should contain a list of Integers, representing the indexes for the given columns contained in the table model.- Parameters:
columnIndex- ArrayList of Integer's which represent the column index of the columns to be set to sortable.
-
setAlphaNumericColumn
public void setAlphaNumericColumn(int columnIndex) Set the specified column, referenced by columnIndex to be an alpha numeric column. Special sorting algorithm will be used for alpha numeric columns.See com.portal.pfc.ui.table.CommonSortRoutines for more details.
- Parameters:
columnIndex- int indicating the column index of the alpha numeric column.
-