Class SortableAndSearchableTableWithButtons<T extends SortableAndSearchableTable>
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- adams.gui.core.BasePanel
-
- adams.gui.core.BasePanelWithButtons
-
- adams.gui.core.AbstractComponentWithButtons<T>
-
- adams.gui.core.AbstractDoubleClickableComponentWithButtons<T>
-
- adams.gui.core.SortableAndSearchableTableWithButtons<T>
-
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,Accessible
public class SortableAndSearchableTableWithButtons<T extends SortableAndSearchableTable> extends AbstractDoubleClickableComponentWithButtons<T>
Graphical component that consists of a SortableAndSearchableTable with buttons on the right-hand side.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
-
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
Fields Modifier and Type Field Description protected TableModelListener
m_CountModelListener
the model listener for updating the counts.-
Fields inherited from class adams.gui.core.AbstractDoubleClickableComponentWithButtons
m_DoubleClickAction, m_DoubleClickButton
-
Fields inherited from class adams.gui.core.AbstractComponentWithButtons
m_Component, m_LabelInfo, m_PanelAll, m_PanelInfo, m_ScrollPane
-
Fields inherited from class adams.gui.core.BasePanelWithButtons
m_LayoutButtons, m_PanelButtons
-
Fields inherited from class adams.gui.core.BasePanel
m_FileChooser
-
Fields inherited from class javax.swing.JComponent
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
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
-
Constructor Summary
Constructors Constructor Description SortableAndSearchableTableWithButtons()
The default constructor.SortableAndSearchableTableWithButtons(TableModel model)
Initializes the table with the specified model.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCellPopupMenuListener(PopupMenuListener l)
Adds the popup menu listeners for the cell.void
addHeaderPopupMenuListener(PopupMenuListener l)
Adds the popup menu listeners for the header.void
addRemoveItemsListener(RemoveItemsListener l)
Adds the remove items listener to its internal list.boolean
canMoveDown()
checks whether the selected items can be moved down.boolean
canMoveUp()
checks whether the selected items can be moved up.int
columnAtPoint(Point point)
Returns the index of the column thatpoint
lies in, or -1 if the result is not in the range [0,getColumnCount()
-1].protected T
createComponent()
Creates the component to use in the panel.int
getActualRow(int visibleRow)
Returns the actual underlying row the given visible one represents.int
getAutoResizeMode()
Returns the auto resize mode of the table.Class<?>
getColumnClass(int column)
Returns the type of the column appearing in the view at column positioncolumn
.int
getColumnCount()
Returns the number of columns in the column model.TableColumnModel
getColumnModel()
Returns theTableColumnModel
that contains all column information of this table.String
getColumnName(int column)
Returns the name of the column appearing in the view at column positioncolumn
.T
getComponent()
Returns the underlying component.int
getDisplayRow(int internalRow)
Returns the "visible" row derived from row in the actual table model.TableModel
getModel()
Returns the underlying table model.int
getRowCount()
Returns the number of rows that can be shown in theJTable
, given unlimited space.int
getRowHeight(int row)
Returns the height for the specified row.String
getSeachString()
Returns the current search string.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.ListSelectionModel
getSelectionModel()
Returns theListSelectionModel
that is used to maintain row selection state.boolean
getShowSimpleCellPopupMenu()
Returns whether to show a simple cell popup menu.boolean
getShowSimpleHeaderPopupMenu()
Returns whether to show a simple header popup menu.TableModel
getUnsortedModel()
Returns the underlying table model.Object
getValueAt(int row, int column)
Returns the cell value atrow
andcolumn
.void
invertSelection()
Inverts the selection.boolean
isCellEditable(int row, int column)
Returns true if the cell atrow
andcolumn
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
isRegExpSearch()
Returns whether the last search was a regular expression based one.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.protected boolean
isValidDoubleClick(MouseEvent e)
Checks whether the double click is valid for this component.void
moveBottom()
moves the selected items to the end.void
moveDown()
moves the selected items down by 1.void
moveTop()
moves the selected items to the top.void
moveUp()
moves the selected items up by 1.void
removeCellPopupMenuListener(PopupMenuListener l)
Removes the popup menu listener for the cell from its internal list.void
removeHeaderPopupMenuListener(PopupMenuListener l)
Removes the popup menu listener for the header from its internal list.void
removeRemoveItemsListener(RemoveItemsListener l)
Removes the remove items listener from its internal list.boolean
requiresScrollPane()
Returns whether the component requires a JScrollPane around it.int
rowAtPoint(Point point)
Returns the index of the row thatpoint
lies in, or -1 if the result is not in the range [0,getRowCount()
-1].void
scrollColumnToVisible(int col)
Scrolls the column into view.void
scrollRowToVisible(int row)
Scrolls the row into view.void
search(String searchString, boolean regexp)
Performs a search for the given string.void
selectAll()
Selects all rows.void
selectNone()
Deselects all rows.void
setAutoResizeMode(int mode)
Sets the table's auto resize mode when the table is resized.void
setColumnModel(TableColumnModel columnModel)
Sets the column model for this table tonewModel
and registers for listener notifications from the new column model.void
setInfoVisible(boolean value)
Whether to display the information JLabel or not.void
setModel(TableModel dataModel)
Sets the data model for this table tonewModel
and registers with it for listener notifications from the new data model.void
setOptimalColumnWidth()
Sets the optimal column width for all columns.void
setOptimalColumnWidth(int column)
Sets the optimal column width for the specified column.void
setOptimalColumnWidthBounded(int max)
Sets the optimal column width for all columns.void
setOptimalColumnWidthBounded(int column, int max)
Sets the optimal column width for the specified column.void
setRowHeight(int rowHeight)
Sets the height, in pixels, of all cells torowHeight
, revalidates, and repaints.void
setSelectedRow(int row)
Sets the selected row (clears all others).void
setSelectedRows(int[] rows)
Sets the selected rows (clears all others).void
setSelectionMode(int selectionMode)
Sets the table's selection mode to allow only single selections, a single contiguous interval, or multiple intervals.void
setSelectionModel(ListSelectionModel newModel)
Sets the row selection model for this table tonewModel
and registers for listener notifications from the new selection model.void
setShowSimpleCellPopupMenu(boolean value)
Sets whether to show a simple cell popup menu.void
setShowSimpleHeaderPopupMenu(boolean value)
Sets whether to show a simple header popup menu.void
setShowSimplePopupMenus(boolean value)
Sets whether to show a simple header/cell popup menu.void
setUnsortedModel(TableModel dataModel)
Sets the data model for this table tonewModel
and registers with it for listener notifications from the new data model.void
setUnsortedModel(TableModel dataModel, boolean restoreSorting)
Sets the data model for this table tonewModel
and registers with it for listener notifications from the new data model.void
setValueAt(Object aValue, int row, int column)
Sets the value for the cell in the table model atrow
andcolumn
.boolean
supportsMovingRows()
Returns whether the table model supports moving of rows.protected void
updateCounts()
Updates the information about the counts.protected void
updateCountsModelListener(TableModel dataModel)
Updates the table model's listener for updating the counts.-
Methods inherited from class adams.gui.core.AbstractDoubleClickableComponentWithButtons
getDoubleClickAction, getDoubleClickButton, initGUI, setDoubleClickAction, setDoubleClickButton
-
Methods inherited from class adams.gui.core.AbstractComponentWithButtons
addKeyListener, getScrollPane, isInfoVisible, removeKeyListener, updateInfo
-
Methods inherited from class adams.gui.core.BasePanelWithButtons
addToButtonsPanel, clearButtonsPanel, removeFromButtonsPanel
-
Methods inherited from class adams.gui.core.BasePanel
afterHide, afterShow, beforeHide, beforeShow, closeParent, finishInit, getParentChild, getParentDialog, getParentFrame, getParentInternalFrame, getParentTitle, initFileChooser, initialize, main, printErrorMessage, printException, saveComponent, setEnabledCascade, setEnabledCascade, setParentTitle, setVisible
-
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
-
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, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, 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, 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, setLayout, transferFocusDownCycle, validate, validateTree
-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, 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, 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
-
-
-
-
Field Detail
-
m_CountModelListener
protected TableModelListener m_CountModelListener
the model listener for updating the counts.
-
-
Constructor Detail
-
SortableAndSearchableTableWithButtons
public SortableAndSearchableTableWithButtons()
The default constructor.
-
SortableAndSearchableTableWithButtons
public SortableAndSearchableTableWithButtons(TableModel model)
Initializes the table with the specified model.- Parameters:
model
- the model to use
-
-
Method Detail
-
requiresScrollPane
public boolean requiresScrollPane()
Returns whether the component requires a JScrollPane around it.- Specified by:
requiresScrollPane
in classAbstractComponentWithButtons<T extends SortableAndSearchableTable>
- Returns:
- true if the component requires a JScrollPane
-
createComponent
protected T createComponent()
Creates the component to use in the panel. If a- Specified by:
createComponent
in classAbstractComponentWithButtons<T extends SortableAndSearchableTable>
- Returns:
- the component
-
getComponent
public T getComponent()
Returns the underlying component.- Overrides:
getComponent
in classAbstractComponentWithButtons<T extends SortableAndSearchableTable>
- Returns:
- the underlying component
-
isValidDoubleClick
protected boolean isValidDoubleClick(MouseEvent e)
Checks whether the double click is valid for this component.- Specified by:
isValidDoubleClick
in classAbstractDoubleClickableComponentWithButtons<T extends SortableAndSearchableTable>
- Parameters:
e
- the mouse event of the double click- Returns:
- true if valid double click
-
setModel
public void setModel(TableModel dataModel)
Sets the data model for this table tonewModel
and registers with it for listener notifications from the new data model.- Parameters:
dataModel
- the new data source for this table- See Also:
getModel()
-
getModel
public TableModel getModel()
Returns the underlying table model.- Returns:
- the underlying table model
-
setUnsortedModel
public void setUnsortedModel(TableModel dataModel)
Sets the data model for this table tonewModel
and registers with it for listener notifications from the new data model.- Parameters:
dataModel
- the new data source for this table- See Also:
getUnsortedModel()
-
setUnsortedModel
public void setUnsortedModel(TableModel dataModel, boolean restoreSorting)
Sets the data model for this table tonewModel
and registers with it for listener notifications from the new data model.- Parameters:
dataModel
- the new data source for this tablerestoreSorting
- whether to restore the sorting settings- See Also:
getUnsortedModel()
-
getUnsortedModel
public TableModel getUnsortedModel()
Returns the underlying table model.- Returns:
- the underlying table model
-
supportsMovingRows
public boolean supportsMovingRows()
Returns whether the table model supports moving of rows.- Returns:
- true if the model supports moving rows around
- See Also:
MoveableTableModel
-
moveUp
public void moveUp()
moves the selected items up by 1.
-
moveDown
public void moveDown()
moves the selected items down by 1.
-
moveTop
public void moveTop()
moves the selected items to the top.
-
moveBottom
public void moveBottom()
moves the selected items to the end.
-
canMoveUp
public boolean canMoveUp()
checks whether the selected items can be moved up.- Returns:
- true if the selected items can be moved
-
canMoveDown
public boolean canMoveDown()
checks whether the selected items can be moved down.- Returns:
- true if the selected items can be moved
-
setColumnModel
public void setColumnModel(TableColumnModel columnModel)
Sets the column model for this table tonewModel
and registers for listener notifications from the new column model. Also sets the column model of theJTableHeader
tocolumnModel
.- Parameters:
columnModel
- the new data source for this table- Throws:
IllegalArgumentException
- ifcolumnModel
isnull
- See Also:
getColumnModel()
-
getColumnModel
public TableColumnModel getColumnModel()
Returns theTableColumnModel
that contains all column information of this table.- Returns:
- the object that provides the column state of the table
- See Also:
setColumnModel(javax.swing.table.TableColumnModel)
-
setSelectionModel
public void setSelectionModel(ListSelectionModel newModel)
Sets the row selection model for this table tonewModel
and registers for listener notifications from the new selection model.- Parameters:
newModel
- the new selection model- Throws:
IllegalArgumentException
- ifnewModel
isnull
- See Also:
getSelectionModel()
-
getSelectionModel
public ListSelectionModel getSelectionModel()
Returns theListSelectionModel
that is used to maintain row selection state.- Returns:
- the object that provides row selection state,
null
if row selection is not allowed - See Also:
setSelectionModel(javax.swing.ListSelectionModel)
-
setAutoResizeMode
public void setAutoResizeMode(int mode)
Sets the table's auto resize mode when the table is resized.- Parameters:
mode
- One of 5 legal values: AUTO_RESIZE_OFF, AUTO_RESIZE_NEXT_COLUMN, AUTO_RESIZE_SUBSEQUENT_COLUMNS, AUTO_RESIZE_LAST_COLUMN, AUTO_RESIZE_ALL_COLUMNS- See Also:
getAutoResizeMode()
,Container.doLayout()
-
getAutoResizeMode
public int getAutoResizeMode()
Returns the auto resize mode of the table. The default mode is AUTO_RESIZE_SUBSEQUENT_COLUMNS.- Returns:
- the autoResizeMode of the table
- See Also:
setAutoResizeMode(int)
-
setOptimalColumnWidth
public void setOptimalColumnWidth()
Sets the optimal column width for all columns. AutoResize must be set to BaseTable.AUTO_RESIZE_OFF.
-
setOptimalColumnWidth
public void setOptimalColumnWidth(int column)
Sets the optimal column width for the specified column. AutoResize must be set to BaseTable.AUTO_RESIZE_OFF.- Parameters:
column
- the column to resize
-
setOptimalColumnWidthBounded
public void setOptimalColumnWidthBounded(int max)
Sets the optimal column width for all columns. AutoResize must be set to BaseTable.AUTO_RESIZE_OFF.- Parameters:
max
- the maximum width
-
setOptimalColumnWidthBounded
public void setOptimalColumnWidthBounded(int column, int max)
Sets the optimal column width for the specified column. AutoResize must be set to BaseTable.AUTO_RESIZE_OFF.- Parameters:
column
- the column to resizemax
- the maximum width
-
setRowHeight
public void setRowHeight(int rowHeight)
Sets the height, in pixels, of all cells torowHeight
, revalidates, and repaints. The height of the cells will be equal to the row height minus the row margin.- Parameters:
rowHeight
- new row height
-
getRowHeight
public int getRowHeight(int row)
Returns the height for the specified row.- Parameters:
row
- the row to get the height in pixels for- Returns:
- the row height
-
rowAtPoint
public int rowAtPoint(Point point)
Returns the index of the row thatpoint
lies in, or -1 if the result is not in the range [0,getRowCount()
-1].- Parameters:
point
- the location of interest- Returns:
- the index of the row that
point
lies in, or -1 if the result is not in the range [0,getRowCount()
-1]
-
columnAtPoint
public int columnAtPoint(Point point)
Returns the index of the column thatpoint
lies in, or -1 if the result is not in the range [0,getColumnCount()
-1].- Parameters:
point
- the location of interest- Returns:
- the index of the column that
point
lies in, or -1 if the result is not in the range [0,getColumnCount()
-1] - See Also:
rowAtPoint(java.awt.Point)
-
selectAll
public void selectAll()
Selects all rows.
-
selectNone
public void selectNone()
Deselects all rows.
-
invertSelection
public void invertSelection()
Inverts the selection.
-
getSelectedRow
public int getSelectedRow()
Returns the index of the first selected row, -1 if no row is selected.- Returns:
- the index of the first selected row
-
setSelectedRow
public void setSelectedRow(int row)
Sets the selected row (clears all others).- Parameters:
row
- the row to select
-
getSelectedColumn
public int getSelectedColumn()
Returns the index of the first selected column, -1 if no column is selected.- Returns:
- the index of the first selected column
-
getSelectedRows
public int[] getSelectedRows()
Returns the indices of all selected rows.- Returns:
- an array of integers containing the indices of all selected rows, or an empty array if no row is selected
- See Also:
getSelectedRow()
-
setSelectedRows
public void setSelectedRows(int[] rows)
Sets the selected rows (clears all others).- Parameters:
rows
- the rows to select
-
getSelectedColumns
public int[] getSelectedColumns()
Returns the indices of all selected columns.- 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.- Returns:
- the number of selected rows, 0 if no rows are selected
-
getSelectedColumnCount
public int getSelectedColumnCount()
Returns the number of selected columns.- 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.- 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.- 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.- Parameters:
row
- the row being queriedcolumn
- the column being queried- Returns:
- true if
row
andcolumn
are valid indices and the cell at index(row, column)
is selected, where the first row and first column are at index 0
-
scrollRowToVisible
public void scrollRowToVisible(int row)
Scrolls the row into view.- Parameters:
row
- the row to scroll into view
-
scrollColumnToVisible
public void scrollColumnToVisible(int col)
Scrolls the column into view.- Parameters:
col
- the column to scroll into view
-
getRowCount
public int getRowCount()
Returns the number of rows that can be shown in theJTable
, given unlimited space. If aRowSorter
with a filter has been specified, the number of rows returned may differ from that of the underlyingTableModel
.- Returns:
- the number of rows shown in the
JTable
- See Also:
getColumnCount()
-
getColumnCount
public int getColumnCount()
Returns the number of columns in the column model. Note that this may be different from the number of columns in the table model.- Returns:
- the number of columns in the table
- See Also:
getRowCount()
-
getColumnName
public String getColumnName(int column)
Returns the name of the column appearing in the view at column positioncolumn
.- 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 positioncolumn
.- 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 atrow
andcolumn
.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.- Parameters:
row
- the row whose value is to be queriedcolumn
- 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 atrow
andcolumn
.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.- Parameters:
aValue
- the new valuerow
- the row of the cell to be changedcolumn
- 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 atrow
andcolumn
is editable. Otherwise, invokingsetValueAt
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.- Parameters:
row
- the row whose value is to be queriedcolumn
- the column whose value is to be queried- Returns:
- true if the cell is editable
- See Also:
setValueAt(java.lang.Object, int, int)
-
setSelectionMode
public void setSelectionMode(int selectionMode)
Sets the table's selection mode to allow only single selections, a single contiguous interval, or multiple intervals.- Parameters:
selectionMode
- the selection mode to use- See Also:
JList.setSelectionMode(int)
-
setInfoVisible
public void setInfoVisible(boolean value)
Whether to display the information JLabel or not.- Overrides:
setInfoVisible
in classAbstractComponentWithButtons<T extends SortableAndSearchableTable>
- Parameters:
value
- if true then the information is being displayed
-
updateCountsModelListener
protected void updateCountsModelListener(TableModel dataModel)
Updates the table model's listener for updating the counts.- Parameters:
dataModel
- the model to update
-
updateCounts
protected void updateCounts()
Updates the information about the counts.
-
getActualRow
public int getActualRow(int visibleRow)
Returns the actual underlying row the given visible one represents. Useful for retrieving "non-visual" data that is also stored in a TableModel.- Parameters:
visibleRow
- the displayed row to retrieve the original row for- Returns:
- the original row
-
getDisplayRow
public int getDisplayRow(int internalRow)
Returns the "visible" row derived from row in the actual table model.- Parameters:
internalRow
- the row in the actual model- Returns:
- the row in the sorted model, -1 in case of an error
-
addRemoveItemsListener
public void addRemoveItemsListener(RemoveItemsListener l)
Adds the remove items listener to its internal list.- Parameters:
l
- the listener to add
-
removeRemoveItemsListener
public void removeRemoveItemsListener(RemoveItemsListener l)
Removes the remove items listener from its internal list.- Parameters:
l
- the listener to remove
-
addHeaderPopupMenuListener
public void addHeaderPopupMenuListener(PopupMenuListener l)
Adds the popup menu listeners for the header.- Parameters:
l
- the listener to add
-
removeHeaderPopupMenuListener
public void removeHeaderPopupMenuListener(PopupMenuListener l)
Removes the popup menu listener for the header from its internal list.- Parameters:
l
- the listener to remove
-
addCellPopupMenuListener
public void addCellPopupMenuListener(PopupMenuListener l)
Adds the popup menu listeners for the cell.- Parameters:
l
- the listener to add
-
removeCellPopupMenuListener
public void removeCellPopupMenuListener(PopupMenuListener l)
Removes the popup menu listener for the cell from its internal list.- Parameters:
l
- the listener to remove
-
search
public void search(String searchString, boolean regexp)
Performs a search for the given string. Limits the display of rows to ones containing the search string.- Parameters:
searchString
- the string to search forregexp
- whether to perform regular expression matching or just plain string comparison
-
getSeachString
public String getSeachString()
Returns the current search string.- Returns:
- the search string, null if not filtered
-
isRegExpSearch
public boolean isRegExpSearch()
Returns whether the last search was a regular expression based one.- Returns:
- true if last search was a reg exp one
-
setShowSimplePopupMenus
public void setShowSimplePopupMenus(boolean value)
Sets whether to show a simple header/cell popup menu.- Parameters:
value
- true if to show menus
-
setShowSimpleHeaderPopupMenu
public void setShowSimpleHeaderPopupMenu(boolean value)
Sets whether to show a simple header popup menu.- Parameters:
value
- true if to show menu
-
getShowSimpleHeaderPopupMenu
public boolean getShowSimpleHeaderPopupMenu()
Returns whether to show a simple header popup menu.- Returns:
- true if to show menu
-
setShowSimpleCellPopupMenu
public void setShowSimpleCellPopupMenu(boolean value)
Sets whether to show a simple cell popup menu.- Parameters:
value
- true if to show menu
-
getShowSimpleCellPopupMenu
public boolean getShowSimpleCellPopupMenu()
Returns whether to show a simple cell popup menu.- Returns:
- true if to show menu
-
-