Class ExactTable
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JTable
table.ExactTable
- All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, EventListener, Accessible, CellEditorListener, ListSelectionListener, RowSorterListener, TableColumnModelListener, TableModelListener, Scrollable
- Direct Known Subclasses:
CacheSectionPanel.ClassSwitchTable, ClassSwitchSectionPanel.ClassSwitchTable, NumberOfCustomersPanel.PopulationVectorTable, PAResultsWindow.ValuesTable, ReferenceStationPanel.STTable, ResultsTable, SimulationPanel.PreloadingTable
a table with some improvements:
- has a click-aware header
- has a click-aware row header
- "more rows" and "more columns" warning icons
- clipboard transfer of cell values (support depends on the underlying data model) - CTRL+C, CTRL+X, CTRL+V
- can clear selected cells - DELETE
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class JTable
JTable.AccessibleJTable, JTable.DropLocation, JTable.PrintModeNested classes/interfaces inherited from class JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected Clipboardprotected booleanprotected JLabelprotected Stringprotected JLabelprotected Stringprotected ExactTable.MouseHandlerprotected booleanprotected RowHeaderprotected intprotected AbstractActionprotected JButtonprotected booleanprotected Stringprotected TableSelectionListenerFields inherited from class 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 JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanPaste()voidprotected voidduplicated to avoid repeating the same checks multiple timesvoidprotected JTableHeaderOverridden to return our nifty headerbooleanintintgetScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction) intgetScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) Try to keep the viewport aligned on column boundaries in the direction of interestprotected voidprotected voidprotected voidinstallKeyboardAction(InputMap im, ActionMap am, Action a) protected voidbooleanbooleanprotected JPopupMenuvoidvoidOverridden to stop editingvoidsetBatchEditingEnabled(boolean batchEditingEnabled) voidsetColumnSelectionAllowed(boolean allowed) voidsetDisplaysScrollLabels(boolean displaysScrollLabels) voidsetMoreColumnsTooltip(String moreColumnsTooltip) voidsetMoreRowsTooltip(String moreRowsTooltip) voidsetMouseMenuEnabled(boolean mouseMenuEnabled) voidsetRowHeaderWidth(int rowHeaderWidth) voidsetRowSelectionAllowed(boolean allowed) voidsetSelectAllStatus(boolean allowed) voidsetSelectAllTooltip(String selectAllTooltip) voidsetSelectedCell(int row, int col) selects a cellvoidMake sure we're not editing a cell.voidOverridden to make sure column sizes are maintainedprotected voidvoidupdate()protected voidUpdates the state of the actions.voidupdateRow(int row) voidupdateRows(int firstRow, int lastRow) voidMethods inherited from class JTable
addColumn, addColumnSelectionInterval, addNotify, addRowSelectionInterval, changeSelection, clearSelection, columnAdded, columnAtPoint, columnMarginChanged, columnMoved, columnRemoved, columnSelectionChanged, convertColumnIndexToModel, convertColumnIndexToView, convertRowIndexToModel, convertRowIndexToView, createDefaultColumnModel, createDefaultColumnsFromModel, createDefaultDataModel, createDefaultEditors, createDefaultRenderers, createDefaultSelectionModel, 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, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, 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, setAutoCreateColumnsFromModel, setAutoCreateRowSorter, setAutoResizeMode, setCellEditor, setCellSelectionEnabled, setColumnModel, setColumnSelectionInterval, setDefaultEditor, setDefaultRenderer, setDragEnabled, setDropMode, setEditingColumn, setEditingRow, setFillsViewportHeight, setGridColor, setIntercellSpacing, setModel, setPreferredScrollableViewportSize, setRowHeight, setRowHeight, setRowMargin, setRowSelectionInterval, setRowSorter, setSelectionBackground, setSelectionForeground, setSelectionMode, setSelectionModel, setShowGrid, setShowHorizontalLines, setShowVerticalLines, setSurrendersFocusOnKeystroke, setTableHeader, setUI, setUpdateSelectionOnSort, setValueAt, sizeColumnsToFit, sizeColumnsToFit, sorterChanged, updateUI, valueChangedMethods inherited from class 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 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 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
-
Field Details
-
rowHeader
-
rowHeaderWidth
protected int rowHeaderWidth -
selectAllButton
-
moreColumnsLabel
-
moreRowsLabel
-
displaysScrollLabels
protected boolean displaysScrollLabels -
selectAllEnabled
protected boolean selectAllEnabled -
batchEditingEnabled
protected boolean batchEditingEnabled -
selectionListener
-
mouseHandler
-
mouseMenuEnabled
protected boolean mouseMenuEnabled -
clipboard
-
selectAllTooltip
-
moreColumnsTooltip
-
moreRowsTooltip
-
selectAction
-
CUT_ACTION
-
COPY_ACTION
-
PASTE_ACTION
-
CLEAR_ACTION
-
-
Constructor Details
-
ExactTable
-
-
Method Details
-
installKeyboard
protected void installKeyboard() -
installKeyboardAction
-
installKeyboardAction
-
installMouse
protected void installMouse() -
makeMouseMenu
-
tableChanged
Overridden to make sure column sizes are maintained- Specified by:
tableChangedin interfaceTableModelListener- Overrides:
tableChangedin classJTable
-
setRowSelectionAllowed
public void setRowSelectionAllowed(boolean allowed) - Overrides:
setRowSelectionAllowedin classJTable
-
setColumnSelectionAllowed
public void setColumnSelectionAllowed(boolean allowed) - Overrides:
setColumnSelectionAllowedin classJTable
-
setSelectAllStatus
public void setSelectAllStatus(boolean allowed) -
createDefaultTableHeader
Overridden to return our nifty header- Overrides:
createDefaultTableHeaderin classJTable
-
configureEnclosingScrollPane
protected void configureEnclosingScrollPane()duplicated to avoid repeating the same checks multiple times- Overrides:
configureEnclosingScrollPanein classJTable
-
unconfigureEnclosingScrollPane
protected void unconfigureEnclosingScrollPane()- Overrides:
unconfigureEnclosingScrollPanein classJTable
-
stopEditing
public void stopEditing()Make sure we're not editing a cell. NOTE: requires the editor to honor stopCellEditing() or cancelCellEditing() calls. -
setSelectedCell
public void setSelectedCell(int row, int col) selects a cell -
selectAll
-
updateActions
protected void updateActions()Updates the state of the actions. called whenever the selection state of the table changes. -
updateStructure
public void updateStructure() -
update
public void update() -
updateRow
public void updateRow(int row) -
updateRows
public void updateRows(int firstRow, int lastRow) -
getRowHeaderWidth
public int getRowHeaderWidth() -
setRowHeaderWidth
public void setRowHeaderWidth(int rowHeaderWidth) -
getSelectAllTooltip
-
setSelectAllTooltip
-
getMoreRowsTooltip
-
setMoreRowsTooltip
-
getMoreColumnsTooltip
-
setMoreColumnsTooltip
-
displaysScrollLabels
public boolean displaysScrollLabels() -
setDisplaysScrollLabels
public void setDisplaysScrollLabels(boolean displaysScrollLabels) -
getScrollableUnitIncrement
Try to keep the viewport aligned on column boundaries in the direction of interest- Specified by:
getScrollableUnitIncrementin interfaceScrollable- Overrides:
getScrollableUnitIncrementin classJTable
-
getScrollableBlockIncrement
- Specified by:
getScrollableBlockIncrementin interfaceScrollable- Overrides:
getScrollableBlockIncrementin classJTable
-
isBatchEditingEnabled
public boolean isBatchEditingEnabled() -
setBatchEditingEnabled
public void setBatchEditingEnabled(boolean batchEditingEnabled) -
isMouseMenuEnabled
public boolean isMouseMenuEnabled() -
setMouseMenuEnabled
public void setMouseMenuEnabled(boolean mouseMenuEnabled) -
copyCells
public void copyCells() -
clearCells
public void clearCells() -
pasteCells
public void pasteCells() -
canPaste
public boolean canPaste()
-