public class PFCTable extends JTable
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)
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.
JTable.AccessibleJTable, JTable.DropLocation, JTable.PrintMode
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
AUTO_RESIZE_ALL_COLUMNS, AUTO_RESIZE_LAST_COLUMN, AUTO_RESIZE_NEXT_COLUMN, AUTO_RESIZE_OFF, AUTO_RESIZE_SUBSEQUENT_COLUMNS, autoCreateColumnsFromModel, autoResizeMode, cellEditor, cellSelectionEnabled, columnModel, dataModel, defaultEditorsByColumnClass, defaultRenderersByColumnClass, editingColumn, editingRow, editorComp, gridColor, preferredViewportSize, rowHeight, rowMargin, rowSelectionAllowed, selectionBackground, selectionForeground, selectionModel, showHorizontalLines, showVerticalLines, tableHeader
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
PFCTable()
Constructs a default
PFCTable that 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 a
PFCTable with
numRows and numColumns of empty cells using
DefaultTableModel . |
PFCTable(int numRows,
int numColumns,
boolean sortable)
Convenience method that constructs a
PFCTable with
numRows and numColumns of empty cells using
DefaultTableModel . |
PFCTable(Object[][] rowData,
Object[] columnNames)
Convenience method that constructs a
PFCTable to display the
values in the two dimensional array, rowData , with
column names, columnNames . |
PFCTable(Object[][] rowData,
Object[] columnNames,
boolean sortable)
Convenience method that constructs a
PFCTable to display the
values in the two dimensional array, rowData , with
column names, columnNames . |
PFCTable(TableModel model)
Convenience method that constructs a default
PFCTable
that 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 default
PFCTable
that is initialized with a DefaultTableModel model, and by default sets
all columns to either be sortable or not, based upon the specified
sortable value. |
PFCTable(Vector rowData,
Vector columnNames)
Convenience method that constructs a
PFCTable to display the
values in the Vector of Vectors , rowData
, with column names, columnNames . |
PFCTable(Vector rowData,
Vector columnNames,
boolean sortable)
Constructs a
PFCTable to display the values in the
Vector of Vectors , rowData ,
with column names, columnNames . |
Modifier and Type | Method and Description |
---|---|
boolean |
isColumnSortable(int columnIndex)
Returns whether specified column in the table is sortable.
|
boolean |
isTableSortable()
Returns whether all columns in the table are sortable.
|
void |
setAlphaNumericColumn(int columnIndex)
Set the specified column, referenced by columnIndex to be an alpha numeric
column.
|
void |
setModel(TableModel newModel)
Sets the data model for this table to
newModel and registers
with it for listener notifications from the new data model. |
void |
setModel(TableModel newModel,
boolean sortable)
Sets the data model for this table to
newModel and registers
with it for listener notifications from the new data model. |
void |
setSortable(boolean sortable)
Sets all the columns in the table to be sortable.
|
void |
setSortableColumn(int columnIndex)
Sets the specified column, referenced by columnIndex to be sortable.
|
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.
|
void |
setSortableColumns(ArrayList columnList)
Sets the specified columns, contained in the columnList ArrayList to
be sortable.
|
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, valueChanged
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, update
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, validateTree
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, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public PFCTable()
PFCTable
that is initialized with a default
data model, a default column model, and a default selection
model.
To set a TableModel, call setModel(TableModel model)
which
will set the table to be sortable by default or
setTableModel(TableModel model, boolean sortable), which will set the
table to be sortable, based upon specified sortable value.
public PFCTable(TableModel model)
PFCTable
that is initialized with a TableModel model, and by default sets
all columns to be sortable. To construct a default PFCTable
that is not sortable, use PFCTable(TableModel model,
boolean sortable)
with sortable set to false.model
- the data model for the table.public PFCTable(TableModel model, boolean sortable)
PFCTable
that is initialized with a DefaultTableModel model, and by default sets
all columns to either be sortable or not, based upon the specified
sortable value.model
- the data model for the table.sortable
- true (sortable), false (not sortable).public PFCTable(int numRows, int numColumns)
PFCTable
with
numRows
and numColumns
of empty cells using
DefaultTableModel
. By default, all columns will be set to be
sortable. To set the columns to not be sortable, use
PFCTable(int numRows, int numColumns, boolean sortable)
with
sortable set to false.
The columns will have names of the form "A", "B", "C", etc.numRows
- the number of rows the table holdsnumColumns
- the number of columns the table holdsDefaultTableModel
public PFCTable(int numRows, int numColumns, boolean sortable)
PFCTable
with
numRows
and numColumns
of empty cells using
DefaultTableModel
. 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.numRows
- the number of rows the table holdsnumColumns
- the number of columns the table holdssortable
- true (sortable), false (not sortable).DefaultTableModel
public PFCTable(Vector rowData, Vector columnNames)
PFCTable
to display the
values in the Vector
of Vectors
, rowData
, with column names, columnNames
. The
Vectors
contained in rowData
should contain the values for that row. In other words,
the value of the cell at row 1, column 5 can be obtained
with the following code:
((Vector)rowData.elementAt(1)).elementAt(5);
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.
rowData
- the data for the new tablecolumnNames
- names of each columnpublic PFCTable(Vector rowData, Vector columnNames, boolean sortable)
PFCTable
to display the values in the
Vector
of Vectors
, rowData
,
with column names, columnNames
. The
Vectors
contained in rowData
should contain the values for that row. In other words,
the value of the cell at row 1, column 5 can be obtained
with the following code:
((Vector)rowData.elementAt(1)).elementAt(5);
rowData
- the data for the new tablecolumnNames
- names of each columnsortable
- true (sortable), false (not sortable).public PFCTable(Object[][] rowData, Object[] columnNames)
PFCTable
to display the
values in the two dimensional array, rowData
, with
column names, columnNames
. rowData
is an array
of rows, so the value of the cell at row 1,
column 5 can be obtained with the following code:
rowData[1][5];
All rows must be of the same length as columnNames
.
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.
rowData
- the data for the new tablecolumnNames
- names of each columnpublic PFCTable(Object[][] rowData, Object[] columnNames, boolean sortable)
PFCTable
to display the
values in the two dimensional array, rowData
, with
column names, columnNames
. rowData
is an array
of rows, so the value of the cell at row 1,
column 5 can be obtained with the following code:
rowData[1][5];
All rows must be of the same length as columnNames
.
Columns will be set to be either be sortable or not, based upon the sortable value.
rowData
- the data for the new tablecolumnNames
- names of each columnsortable
- true (sortable), false (not sortable)public void setModel(TableModel newModel, boolean sortable)
newModel
and registers
with it for listener notifications from the new data model. Previous
listeners will be removed.newModel
- the new data source for this tablesortable
- true (sortable), false (not sortable)public void setModel(TableModel newModel)
newModel
and registers
with it for listener notifications from the new data model. Previous
listeners will be removed. By default, the table will be sortable.public void setSortable(boolean sortable)
sortable
- true (sortable), false (not sortable).public boolean isTableSortable()
public boolean isColumnSortable(int columnIndex)
columnIndex
- index of the column to setpublic void setSortableColumn(int columnIndex)
columnIndex
- int indicating the column index of the column to be
sortable.columnIndex
- index of the column to setpublic void setSortableColumn(int columnIndex, boolean sortable)
columnIndex
- index of the column to setsortable
- true (sortable), false (not sortable)public void setSortableColumns(ArrayList columnList)
columnIndex
- ArrayList of Integer's which represent the column index
of the columns to be set to sortable.public void setAlphaNumericColumn(int columnIndex)
See com.portal.pfc.ui.table.CommonSortRoutines for more details.
columnIndex
- int indicating the column index of the alpha numeric
column.Copyright © 2003, 2023, Oracle and/or its affiliates.