JIDE 2.9.5

com.jidesoft.grid
Class JideTable

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JTable
                  extended by com.jidesoft.grid.JideTable
All Implemented Interfaces:
IndexChangeListener, TableAdapter, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, CellEditorListener, ListSelectionListener, RowSorterListener, TableColumnModelListener, TableModelListener, Scrollable
Direct Known Subclasses:
ContextSensitiveTable

public class JideTable
extends JTable
implements TableAdapter, IndexChangeListener

JideTable is an extended version of JTable.

There are several features we added to JideTable.

First, we added CellEditorListener support. You can add a JideCellEditorListener to the table. JideCellEditorListener extends CellEditorListener and added additional methods such as JideCellEditorListener.editingStarting(javax.swing.event.ChangeEvent), JideCellEditorListener.editingStopping(javax.swing.event.ChangeEvent) and CellEditorListener.editingStopped(javax.swing.event.ChangeEvent). You can do things like preventing cell from starting edit or preventing cell from stopping edit.

The second feature is to support Validator. You can add a Validator to the table. The validating() method in the listener will be called before cell stops editing. If the validation failed, the cell editor won't be removed.

The third feature added to JideTable is the support of the listener for row height changes when rows have various height. You can add a listener by calling getRowHeights().addRowHeightChangeListener(listener). A RowHeightChangeEvent will be fired whenever setRowHeight(int,int) is called.

The fourth feature is rowAutoResizes. By default, JTable's row height is determined explicitly. It wouldn't consider the cell content preferred height. There is a problem here if a cell renderer can support multiple lines. So we added a new attribute called rowAutoResizes. By default, it's false which is exactly the same behavior as JTable. If you set to true, the table row will resize automatically when cell renderer's preferred height changes. Please note there is a performance hit if you turned it on as it has to check all cells to find out the preferred row height. So only use it when it's really necessary.

In the future, we will add more features to JideTable as long as we think the feature should be part of the base table class.

Please be noted that, JideTable could NOT support the sorter provided in JTable. The reason is that, JTable contains many private method and fields in that area, which prevents us to inherit its behavior. For sorting feature in JideTable, please use SortableTable instead.

See Also:
Serialized Form

Nested Class Summary
protected static class JideTable.NonContiguousTransferHandler
           
 
Nested classes/interfaces inherited from class javax.swing.JTable
JTable.AccessibleJTable, JTable.DropLocation, JTable.PrintMode
 
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  boolean _batchProcessing
           
protected  CellChangeEvent _cellChangeEvent
           
protected  int _clickCountToStart
          An integer specifying the number of clicks needed to start editing.
protected  TableColumnAutoResizer _columnAutoResizer
           
protected  TableColumnResizer _columnResizer
           
protected  MouseMotionListener _headerDraggingMouseMotionListener
           
protected  RowHeights _rowHeights
           
protected  TableRowResizer _rowResizer
           
static int AUTO_RESIZE_ALL_COLUMNS_FILL
          Deprecated. please use AUTO_RESIZE_FILL | AUTO_RESIZE_ALL_COLUMNS instead.
static int AUTO_RESIZE_FILL
          An enhanced auto resize mode.
static int AUTO_RESIZE_LAST_COLUMN_FILL
          Deprecated. please use AUTO_RESIZE_FILL | AUTO_RESIZE_LAST_COLUMN instead.
static int AUTO_RESIZE_NEXT_COLUMN_FILL
          Deprecated. please use AUTO_RESIZE_FILL | AUTO_RESIZE_NEXT_COLUMN instead.
static int AUTO_RESIZE_SUBSEQUENT_COLUMNS_FILL
          Deprecated. please use AUTO_RESIZE_FILL | AUTO_RESIZE_SUBSEQUENT_COLUMNS instead.
static int EDITOR_AUTO_COMPLETION_MODE_COLUMN
           
static int EDITOR_AUTO_COMPLETION_MODE_NONE
           
static int EDITOR_AUTO_COMPLETION_MODE_ROW
           
static int EDITOR_AUTO_COMPLETION_MODE_TABLE
           
static String PROPERTY_CLEAR_SELECTION_ON_TABLE_DATA_CHANGES
           
static String PROPERTY_EDITOR_AUTO_COMPLETION_MODE
           
static String PROPERTY_NON_CONTIGUOUS_CELL_SELECTION
           
static String PROPERTY_ROW_AUTO_RESIZES
           
static String PROPERTY_SCROLL_ROW_WHEN_ROW_HEIGHT_CHANGES
           
static String PROPERTY_TABLE_SELECTION_MODEL
           
static String ROW_AUTO_RESIZES_PROPERTY
          Deprecated. renamed to PROPERTY_ROW_AUTO_RESIZES
 
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, tableHeader
 
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 java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JideTable()
           
JideTable(int numRows, int numColumns)
           
JideTable(Object[][] rowData, Object[] columnNames)
           
JideTable(TableModel dm)
           
JideTable(TableModel dm, TableColumnModel cm)
           
JideTable(TableModel dm, TableColumnModel cm, ListSelectionModel sm)
           
JideTable(Vector<?> rowData, Vector<?> columnNames)
           
 
Method Summary
 void addCellEditorListener(JideCellEditorListener l)
          Adds a JideCellEditorListener to the listener list.
 void addColumn(TableColumn column)
          Overrides this method to skip the column that is being added when the column was hidden earlier by TableColumnChooser.hideColumn(javax.swing.JTable, int) method.
 void addNotify()
           
 void addRowValidator(RowValidator l)
          Adds a RowValidator to the listener list.
 void addValidator(Validator l)
          Adds a Validator to the listener list.
 void adjustSelectionWhenColumnMoved(int column, int targetColumn)
          Usually you don't need to call this method.
 boolean alwaysCalculateCellRect()
          A boolean flag to determine if the rect should always be calculated when painting the grid line and cells.
protected  void calculateAutoResizedRowHeights()
           
protected  void calculateAutoResizedRowHeights(int firstRow, int lastRow)
           
protected  int calculateRowHeight(int row)
          The method calculates the height for the row based on the content in the row.
 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()
           
 void clearSelectionPermanently()
          Clear the selections permanently without being restored later on.
 void columnAdded(TableColumnModelEvent e)
           
 void columnMoved(TableColumnModelEvent e)
           
 void columnRemoved(TableColumnModelEvent e)
           
 void configureEnclosingScrollPaneExplicitly()
           
protected  String convertElementToString(Object value, int row, int column)
          Get the displayed string of the specified value in designated row and column.
 int convertRowIndexToModel(int viewRowIndex)
          Overrides this methods so that it is available for pre-JDK6 environment.
 int convertRowIndexToView(int modelRowIndex)
          Overrides this methods so that it is available for pre-JDK6 environment.
 void createDefaultColumnsFromModel()
           
protected  ListSelectionModel createDefaultSelectionModel()
           
protected  JTableHeader createDefaultTableHeader()
          Creates the table header.
 void createDefaultTableSelectionModel()
          Creates a default TableSelectionModel.
protected  RowHeightChangeListener createRowAutoScrollingListener()
          Creates the RowHeightChangeListener which will automatically scroll the row then row height changes so that it is outside the visible area.
protected  RowHeights createRowHeights()
           
protected  SortTableHeaderRenderer createSortHeaderRenderer()
          Creates the header renderer.
 boolean editCellAt(int row, int column, EventObject e)
           
 void editingCanceled(ChangeEvent e)
           
 void editingStopped(ChangeEvent e)
           
protected  void fireEditingCanceled(Object source, int row, int column)
          Notifies all listeners that have registered interest for notification on this event type.
protected  void fireEditingStarted(Object source, int row, int column)
          Notifies all listeners that have registered interest for notification on this event type.
protected  boolean fireEditingStarting(Object source, int row, int column)
          Notifies all listeners that have registered interest for notification on this event type.
protected  void fireEditingStopped(Object source, int row, int column)
          Notifies all listeners that have registered interest for notification on this event type.
protected  boolean fireEditingStopping(Object source, int row, int column)
          Notifies all listeners that have registered interest for notification on this event type.
 int getAutoResizeMode()
           
 CellEditorListener[] getCellEditorListeners()
          Returns an array of all the JideCellEditorListeners added to this JideTable with addCellEditorListener().
 Rectangle getCellRect(int row, int column, boolean includeSpacing)
           
 int getClickCountToStart()
          Returns the number of clicks needed to start editing.
 int getEditorAutoCompletionMode()
          Gets the editor auto-completion mode.
 Rectangle getEditorCellRect(int rowIndex, int columnIndex)
          In TreeTable and HierarchicalTable case, the cell rect for cell editor should consider the +/- icon size so the cell editor doesn't cover the +/- icon.
 Color getGridColor(int row)
          Gets the grid line color for each row.
 int getRowHeight(int row)
           
 RowHeights getRowHeights()
           
 RowValidator[] getRowValidator()
          Returns an array of all the RowValidators added to this AbstractCellEditor with addValidationListener().
 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.
 Color getSelectionBackground()
           
 TableColumnWidthKeeper getTableColumnWidthKeeper()
           
 String getTableHeaderToolTipText(int columnIndex)
          Gets the TableHeader's tooltip for a particular view column index
 String getTableHeaderToolTipText(MouseEvent event)
          Gets the TableHeader's tooltip at the location of mouse event.
 TableSelectionModel getTableSelectionModel()
          Gets the table selection model.
 JTextComponent getTextComponentForEditorComponent(Component component)
          Gets the text component from the editor component.
 String getToolTipText(MouseEvent event)
           
 TransferHandler getTransferHandler()
          Overrides this method to provide our own TransferHandler if isNonContiguousCellSelection() is true only if the original TransferHandler is an instance of UIResource.
 String getUIClassID()
          Returns a string that specifies the name of the L&F class that renders this component.
 Validator[] getValidator()
          Returns an array of all the Validators added to this AbstractCellEditor with addValidationListener().
 Color getVerticalGridColor(int column)
          Gets the grid line color for each column.
 void indexChanged(IndexChangeEvent event)
          Called whenever the table model wrapper is going to have some change.
protected  void initTable()
          Leaves it here for backward compatible reason.
 boolean isAlwaysRequestFocusForEditor()
          Get the flag indicating if JideTable should always request focus for cell editor.
 boolean isAutoSelectTextWhenStartsEditing()
          Checks if the text in the cell editor will be selected when cell starts editing.
 boolean isAutoStartCellEditing()
          Checks if the navigation key stroke will start cell editing.
protected  boolean isAutoStartCellEditingKey(KeyStroke ks)
          Checks if the key stroke will trigger the cell editing.
protected  boolean isBatchProcessing()
          Checks if it is in batch processing.
 boolean isCalculateRowHeightsOnWidthChange()
          Get the flag indicating if JideTable should calculate row heights if column width is changed.
 boolean isCellContentVisible()
          Checks if the table cell content will be painted.
protected  boolean isCellFocused(int rowIndex, int columnIndex)
          Check if the cell is a focused cell inside the table.
 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 isClearPropertyAtStructureChange()
          Get the flag indicating if JideTable should clear properties for table column orders.
 boolean isClearSelectionOnTableDataChanges()
          Checks if the selection should be cleared when tableDataChanged event is fired.
 boolean isColumnAutoResizable()
          Checks if the column is auto-resizable.
 boolean isColumnResizable()
          Checks if the column is resizable by dragging the vertical grid line.
 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 isEnableIgnored()
          Get the flag indicating if the cell will be painted with normal text color even the table is disabled.
 boolean isKeepRowHeights()
          Get if you want to keep row heights after table events, such as sorting and filtering.
 boolean isNestedTableHeader()
          Checks if nested table header is used.
 boolean isNonContiguousCellSelection()
          Checks if the table selection model allows non-contiguous cell selection.
 boolean isRowAutoResizes()
          Checks if row automatically resizes with the cells preferred heights.
protected  boolean isRowHeightChanged(int row, int newHeight)
          The method will check if the new height is different with current height.
 boolean isRowResizable()
          Checks if the row is resizable by dragging the horizontal grid line.
 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 isScrollRowWhenRowHeightChanges()
          Checks the flag whether a row is scrolled to visible when its height changes.
 boolean isSelectInsertedRows()
          Returns the selectInsertedRows flag.
 boolean isTablePrinting()
          Checks if the table is printing.
protected  boolean isValidCellEditingKey(KeyEvent keyEvent)
          Checks if the key event is a valid keystroke to start cell editing.
 boolean isVariousRowHeights()
          Is the table has various row height on each row.
protected  void loadTableRowSettings(boolean invokeOutside)
          To load row heights and selections after you do some big work, like firing table data change event.
 void paintCellOverlay(Graphics g, Component component, int row, int column, Rectangle cellRect)
          Paints the cell overlay.
protected  void paintFillHeader(Graphics g)
          Paint fill header in the right side of the table header if needed.
 Component prepareEditor(TableCellEditor editor, int row, int column)
           
 Component prepareRenderer(TableCellRenderer renderer, int row, int column)
           
 boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed)
           
 void releaseRendererComponent(TableCellRenderer renderer, int row, int column, Component component)
           
 void removeCellEditorListener(JideCellEditorListener l)
          Removes a JideCellEditorListener from the listener list.
 void removeEditor()
          Override to regain focus on JTable when the AbstractComboBox's popup panel has focus.
 void removeNotify()
           
 void removeRowValidator(RowValidator l)
          Removes a RowValidator from the listener list.
 void removeValidator(Validator l)
          Removes a Validator from the listener list.
 int rowAtPoint(Point point)
          Returns the index of the row that point lies in, or -1 if the result is not in the range [0, getRowCount()-1].
protected  void saveTableRowSettings(boolean invokeOutside)
          To save row heights and selections before you do some big work, like firing table data change event.
 void scrollRowToVisible(int row)
          Scroll the row till the row is visible.
 void selectAll()
           
 void setAlwaysRequestFocusForEditor(boolean alwaysRequestFocusForEditor)
          Set the flag indicating if JideTable should always request focus for cell editor.
 void setAutoResizeMode(int mode)
          Sets the table's auto resize mode when the table is resized.
 void setAutoSelectTextWhenStartsEditing(boolean autoSelectTextWhenStartsEditing)
          Sets the flag if the text in the cell editor will be selected when starts editing.
 void setAutoStartCellEditing(boolean autoStartCellEditing)
          Sets the flag if the navigation key stroke will start cell editing.
protected  void setBatchProcessing(boolean batchProcessing)
          Sets to batch processing.
 void setCalculateRowHeightsOnWidthChange(boolean calculateRowHeightsOnWidthChange)
          Set the flag indicating if JideTable should calculate row heights if column width is changed.
 void setCellContentVisible(boolean cellContentVisible)
          Sets the cell content visible or invisible.
 void setClearPropertyAtStructureChange(boolean clearPropertyAtStructureChange)
          Set the flag indicating if JideTable should clear properties for table column orders.
 void setClearSelectionOnTableDataChanges(boolean clearSelectionOnTableDataChanges)
          Sets the clearSelectionOnTableDataChanges attribute.
 void setClickCountToStart(int count)
          Specifies the number of clicks needed to start editing.
 void setColumnAutoResizable(boolean resizable)
          Enable or disable the column auto-resizable.
 void setColumnResizable(boolean resizable)
          Enable or disable the column resizable.
 void setColumnSelectionAllowed(boolean columnSelectionAllowed)
          Sets whether the columns can be selected.
 void setEditorAutoCompletionMode(int editorAutoCompletionMode)
          Sets the editor auto-completion mode.
 void setEnabled(boolean enabled)
           
 void setEnableIgnored(boolean enableIgnored)
          Set the flag indicating if the cell will be painted with the normal text color even the table is disabled.
 void setKeepRowHeights(boolean keepRowHeights)
          Set if you want to keep row heights after table events, such as sorting and filtering.
 void setModel(TableModel dataModel)
           
 void setNestedTableHeader(boolean nestedTableHeader)
          Sets if nested table header is allowed.
 void setNonContiguousCellSelection(boolean nonContiguousCellSelection)
          Sets the attribute of nonContiguousCellSelection.
 void setPreferredSize(Dimension preferredSize)
           
 void setRowAutoResizes(boolean rowAutoResizes)
          Sets the rowAutoResizes attribute.
 void setRowHeight(int rowHeight)
          Sets the height, in pixels, of all cells to rowHeight, re-validates, and repaints.
 void setRowHeight(int row, int rowHeight)
          Sets the height for row to rowHeight, re-validates, and repaints.
 void setRowHeights(RowHeights rowHeights)
           
 void setRowResizable(boolean resizable)
          Enable or disable the row resizable.
 void setRowSelectionAllowed(boolean rowSelectionAllowed)
          Sets whether the rows can be selected.
 void setScrollRowWhenRowHeightChanges(boolean scrollRowWhenRowHeightChanges)
          Sets the flag if the row should be scrolled to visible when the row height changes.
 void setSelectInsertedRows(boolean selectInsertedRows)
          Sets the selectInsertedRow flag.
protected  void setSortTableHeaderRenderer()
          JideTable allows you to have multiple lines in table header.
 void setTableColumnWidthKeeper(TableColumnWidthKeeper tableColumnWidthKeeper)
           
 void setTablePrinting(boolean tablePrinting)
          Sets the table as printing.
 void setTableSelectionModel(TableSelectionModel tableSelectionModel)
          Sets a new TableSelectionModel.
 void setVariousRowHeights(boolean variousRowHeights)
          Sets variousRowHeights.
protected  boolean startCellEditing(CellEditor editor, int row, int column)
          Calls fireEditingStarting and fireEditingStarted, and returns true or false based on the return value of fireEditingStarting.
 void tableChanged(TableModelEvent e)
          Invoked when this table's TableModel generates a TableModelEvent.
 void updateUI()
          Resets the UI property to a value from the current look and feel.
 ValidationResult validate(int rowIndex, int columnIndex, Object oldValue, Object newValue)
           
 ValidationResult validateRow(int rowIndex)
          Validates a row.
 void valueChanged(ListSelectionEvent e)
           
 
Methods inherited from class javax.swing.JTable
addColumnSelectionInterval, addRowSelectionInterval, columnAtPoint, columnMarginChanged, columnSelectionChanged, configureEnclosingScrollPane, convertColumnIndexToModel, convertColumnIndexToView, createDefaultColumnModel, createDefaultDataModel, createDefaultEditors, createDefaultRenderers, createScrollPaneForTable, doLayout, editCellAt, getAccessibleContext, getAutoCreateColumnsFromModel, getAutoCreateRowSorter, getCellEditor, getCellEditor, getCellRenderer, getCellSelectionEnabled, getColumn, getColumnClass, getColumnCount, getColumnModel, getColumnName, getColumnSelectionAllowed, getDefaultEditor, getDefaultRenderer, getDragEnabled, getDropLocation, getDropMode, getEditingColumn, getEditingRow, getEditorComponent, getFillsViewportHeight, getGridColor, getIntercellSpacing, getModel, getPreferredScrollableViewportSize, getPrintable, getRowCount, getRowHeight, getRowMargin, getRowSelectionAllowed, getRowSorter, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectionForeground, getSelectionModel, getShowHorizontalLines, getShowVerticalLines, getSurrendersFocusOnKeystroke, getTableHeader, getUI, getUpdateSelectionOnSort, getValueAt, initializeLocalVars, isCellEditable, isEditing, moveColumn, paramString, print, print, print, print, print, removeColumn, removeColumnSelectionInterval, removeRowSelectionInterval, resizeAndRepaint, setAutoCreateColumnsFromModel, setAutoCreateRowSorter, setCellEditor, setCellSelectionEnabled, setColumnModel, setColumnSelectionInterval, setDefaultEditor, setDefaultRenderer, setDragEnabled, setDropMode, setEditingColumn, setEditingRow, setFillsViewportHeight, setGridColor, setIntercellSpacing, setPreferredScrollableViewportSize, setRowMargin, setRowSelectionInterval, setRowSorter, setSelectionBackground, setSelectionForeground, setSelectionMode, setSelectionModel, setShowGrid, setShowHorizontalLines, setShowVerticalLines, setSurrendersFocusOnKeystroke, setTableHeader, setUI, setUpdateSelectionOnSort, setValueAt, sizeColumnsToFit, sizeColumnsToFit, sorterChanged, unconfigureEnclosingScrollPane
 
Methods 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, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, 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, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, 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, 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, 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, setComponentOrientation, 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
 
Methods inherited from interface com.jidesoft.grid.TableAdapter
getCellSelectionEnabled, getColumnClass, getColumnCount, getColumnName, getColumnSelectionAllowed, getRowCount, getRowSelectionAllowed, getValueAt, isCellEditable, setCellSelectionEnabled, setValueAt
 

Field Detail

_cellChangeEvent

protected transient CellChangeEvent _cellChangeEvent

ROW_AUTO_RESIZES_PROPERTY

@Deprecated
public static final String ROW_AUTO_RESIZES_PROPERTY
Deprecated. renamed to PROPERTY_ROW_AUTO_RESIZES
See Also:
Constant Field Values

PROPERTY_ROW_AUTO_RESIZES

public static final String PROPERTY_ROW_AUTO_RESIZES
See Also:
Constant Field Values

PROPERTY_NON_CONTIGUOUS_CELL_SELECTION

public static final String PROPERTY_NON_CONTIGUOUS_CELL_SELECTION
See Also:
Constant Field Values

PROPERTY_TABLE_SELECTION_MODEL

public static final String PROPERTY_TABLE_SELECTION_MODEL
See Also:
Constant Field Values

PROPERTY_SCROLL_ROW_WHEN_ROW_HEIGHT_CHANGES

public static final String PROPERTY_SCROLL_ROW_WHEN_ROW_HEIGHT_CHANGES
See Also:
Constant Field Values

PROPERTY_CLEAR_SELECTION_ON_TABLE_DATA_CHANGES

public static final String PROPERTY_CLEAR_SELECTION_ON_TABLE_DATA_CHANGES
See Also:
Constant Field Values

PROPERTY_EDITOR_AUTO_COMPLETION_MODE

public static final String PROPERTY_EDITOR_AUTO_COMPLETION_MODE
See Also:
Constant Field Values

AUTO_RESIZE_FILL

public static final int AUTO_RESIZE_FILL
An enhanced auto resize mode. In this mode, if a JideTable is inside a JScrollPane and the width cannot fill the JViewport, JideTable will have the blank area filled like normal table header and cells.

See Also:
Constant Field Values

AUTO_RESIZE_NEXT_COLUMN_FILL

@Deprecated
public static final int AUTO_RESIZE_NEXT_COLUMN_FILL
Deprecated. please use AUTO_RESIZE_FILL | AUTO_RESIZE_NEXT_COLUMN instead.
See Also:
Constant Field Values

AUTO_RESIZE_SUBSEQUENT_COLUMNS_FILL

@Deprecated
public static final int AUTO_RESIZE_SUBSEQUENT_COLUMNS_FILL
Deprecated. please use AUTO_RESIZE_FILL | AUTO_RESIZE_SUBSEQUENT_COLUMNS instead.
See Also:
Constant Field Values

AUTO_RESIZE_LAST_COLUMN_FILL

@Deprecated
public static final int AUTO_RESIZE_LAST_COLUMN_FILL
Deprecated. please use AUTO_RESIZE_FILL | AUTO_RESIZE_LAST_COLUMN instead.
See Also:
Constant Field Values

AUTO_RESIZE_ALL_COLUMNS_FILL

@Deprecated
public static final int AUTO_RESIZE_ALL_COLUMNS_FILL
Deprecated. please use AUTO_RESIZE_FILL | AUTO_RESIZE_ALL_COLUMNS instead.
See Also:
Constant Field Values

_clickCountToStart

protected int _clickCountToStart
An integer specifying the number of clicks needed to start editing. Even if clickCountToStart is defined as zero, it will not initiate until a click occurs.


_headerDraggingMouseMotionListener

protected MouseMotionListener _headerDraggingMouseMotionListener

EDITOR_AUTO_COMPLETION_MODE_NONE

public static final int EDITOR_AUTO_COMPLETION_MODE_NONE
See Also:
Constant Field Values

EDITOR_AUTO_COMPLETION_MODE_COLUMN

public static final int EDITOR_AUTO_COMPLETION_MODE_COLUMN
See Also:
Constant Field Values

EDITOR_AUTO_COMPLETION_MODE_ROW

public static final int EDITOR_AUTO_COMPLETION_MODE_ROW
See Also:
Constant Field Values

EDITOR_AUTO_COMPLETION_MODE_TABLE

public static final int EDITOR_AUTO_COMPLETION_MODE_TABLE
See Also:
Constant Field Values

_rowHeights

protected RowHeights _rowHeights

_batchProcessing

protected boolean _batchProcessing

_columnAutoResizer

protected TableColumnAutoResizer _columnAutoResizer

_rowResizer

protected TableRowResizer _rowResizer

_columnResizer

protected TableColumnResizer _columnResizer
Constructor Detail

JideTable

public JideTable()

JideTable

public JideTable(int numRows,
                 int numColumns)

JideTable

public JideTable(TableModel dm)

JideTable

public JideTable(Object[][] rowData,
                 Object[] columnNames)

JideTable

public JideTable(Vector<?> rowData,
                 Vector<?> columnNames)

JideTable

public JideTable(TableModel dm,
                 TableColumnModel cm)

JideTable

public JideTable(TableModel dm,
                 TableColumnModel cm,
                 ListSelectionModel sm)
Method Detail

initTable

protected void initTable()
Leaves it here for backward compatible reason.


setModel

public void setModel(TableModel dataModel)
Overrides:
setModel in class JTable

setAutoResizeMode

public void setAutoResizeMode(int mode)
Sets the table's auto resize mode when the table is resized.

Comparing to JTable, JideTable provides one more option, AUTO_RESIZE_FILL. With this option, you would be able to paint the empty area of JTable with a stripe effect or table's background color. You could use AUTO_RESIZE_FILL | AUTO_RESIZE_OFF, AUTO_RESIZE_FILL | AUTO_RESIZE_NEXT_COLUMN, etc.

Overrides:
setAutoResizeMode in class JTable
Parameters:
mode - the auto resize mode
See Also:
getAutoResizeMode(), JTable.doLayout()

getAutoResizeMode

public int getAutoResizeMode()
Overrides:
getAutoResizeMode in class JTable

updateUI

public void updateUI()
Resets the UI property to a value from the current look and feel.

Overrides:
updateUI in class JTable
See Also:
JComponent.updateUI()

getUIClassID

public String getUIClassID()
Returns a string that specifies the name of the L&F class that renders this component.

Overrides:
getUIClassID in class JTable
Returns:
the string "JideTableUI"
See Also:
JComponent.getUIClassID(), UIDefaults.getUI(javax.swing.JComponent)

isNestedTableHeader

public boolean isNestedTableHeader()
Checks if nested table header is used. If you want to use nested table header, you need to make sure you call setNestedTableHeader(boolean) and pass in true.

Returns:
true if nested table header is used. Otherwise false.

setNestedTableHeader

public void setNestedTableHeader(boolean nestedTableHeader)
Sets if nested table header is allowed.

Parameters:
nestedTableHeader - true or false.

createDefaultTableHeader

protected JTableHeader createDefaultTableHeader()
Creates the table header. If the nested table header is allowed, it will return an instance of NestedTableHeader. Otherwise, it will return the JTableHeader.

Overrides:
createDefaultTableHeader in class JTable
Returns:
table header

paintFillHeader

protected void paintFillHeader(Graphics g)
Paint fill header in the right side of the table header if needed.

Parameters:
g - the Graphics instance

getTableHeaderToolTipText

public String getTableHeaderToolTipText(MouseEvent event)
Gets the TableHeader's tooltip at the location of mouse event.

Parameters:
event - the mouse event.
Returns:
the tooltip for the column where the mouse is over.

getTableHeaderToolTipText

public String getTableHeaderToolTipText(int columnIndex)
Gets the TableHeader's tooltip for a particular view column index

Parameters:
columnIndex - the view column index.
Returns:
the tooltip for the column where the mouse is over.

processKeyBinding

public boolean processKeyBinding(KeyStroke ks,
                                 KeyEvent e,
                                 int condition,
                                 boolean pressed)
Overrides:
processKeyBinding in class JTable

prepareEditor

public Component prepareEditor(TableCellEditor editor,
                               int row,
                               int column)
Overrides:
prepareEditor in class JTable

convertElementToString

protected String convertElementToString(Object value,
                                        int row,
                                        int column)
Get the displayed string of the specified value in designated row and column.

Parameters:
value - the cell value
row - the row of the cell
column - the column of the cell
Returns:
the string to be displayed in the cell on renderering.

getTextComponentForEditorComponent

public JTextComponent getTextComponentForEditorComponent(Component component)
Gets the text component from the editor component. We need it in order to make it focus and select all the text if isAutoSelectTextWhenStartsEditing() is true.

Please note, this method will only return JTextComponent if the component is JTextComponent, JComboBox, AbstractComboBox or JSpinner. For all other types of components, it will return null. If you have a custom component which also has JTextComponent in it, you would need to override this method to return the right JTextComponent.

Parameters:
component - the component.
Returns:
text component inside the editor component.

startCellEditing

protected boolean startCellEditing(CellEditor editor,
                                   int row,
                                   int column)
Calls fireEditingStarting and fireEditingStarted, and returns true or false based on the return value of fireEditingStarting.

Parameters:
editor - the editor
row - the editing row
column - the editing column
Returns:
true if editing started. Otherwise false.

fireEditingStarting

protected boolean fireEditingStarting(Object source,
                                      int row,
                                      int column)
Notifies all listeners that have registered interest for notification on this event type. The event instance is created lazily.

Parameters:
source - the source of the event
row - the row index
column - the column index
Returns:
true or false. If all listeners return true in editingStarting(), it will return true. If one of the listener returns false, it will return false.

fireEditingStarted

protected void fireEditingStarted(Object source,
                                  int row,
                                  int column)
Notifies all listeners that have registered interest for notification on this event type. The event instance is created lazily.

Parameters:
source - the source of the event
row - the row index
column - the column index
See Also:
EventListenerList

addCellEditorListener

public void addCellEditorListener(JideCellEditorListener l)
Adds a JideCellEditorListener to the listener list.

Parameters:
l - the new listener to be added

removeCellEditorListener

public void removeCellEditorListener(JideCellEditorListener l)
Removes a JideCellEditorListener from the listener list.

Parameters:
l - the listener to be removed

getCellEditorListeners

public CellEditorListener[] getCellEditorListeners()
Returns an array of all the JideCellEditorListeners added to this JideTable with addCellEditorListener().

Returns:
all of the CellEditorListeners added or an empty array if no listeners have been added

addValidator

public void addValidator(Validator l)
Adds a Validator to the listener list.

Parameters:
l - the new listener to be added

removeValidator

public void removeValidator(Validator l)
Removes a Validator from the listener list.

Parameters:
l - the listener to be removed

getValidator

public Validator[] getValidator()
Returns an array of all the Validators added to this AbstractCellEditor with addValidationListener().

Returns:
all of the Validators added or an empty array if no listeners have been added

validate

public ValidationResult validate(int rowIndex,
                                 int columnIndex,
                                 Object oldValue,
                                 Object newValue)

addRowValidator

public void addRowValidator(RowValidator l)
Adds a RowValidator to the listener list.

Parameters:
l - the new listener to be added

removeRowValidator

public void removeRowValidator(RowValidator l)
Removes a RowValidator from the listener list.

Parameters:
l - the listener to be removed

getRowValidator

public RowValidator[] getRowValidator()
Returns an array of all the RowValidators added to this AbstractCellEditor with addValidationListener().

Returns:
all of the RowValidators added or an empty array if no listeners have been added

validateRow

public ValidationResult validateRow(int rowIndex)
Validates a row. It will use RowValidators added using addRowValidator(com.jidesoft.validation.RowValidator) to do the validation.

Parameters:
rowIndex - the row index.
Returns:
ValidationResult

editingStopped

public void editingStopped(ChangeEvent e)
Specified by:
editingStopped in interface CellEditorListener
Overrides:
editingStopped in class JTable

editingCanceled

public void editingCanceled(ChangeEvent e)
Specified by:
editingCanceled in interface CellEditorListener
Overrides:
editingCanceled in class JTable

fireEditingStopping

protected boolean fireEditingStopping(Object source,
                                      int row,
                                      int column)
Notifies all listeners that have registered interest for notification on this event type. The event instance is created lazily.

Parameters:
source - the source of the event
row - the row index
column - the column index
Returns:
true or false. If all listeners return true in editingStarting(), it will return true. If one of the listener returns false, it will return false.

fireEditingStopped

protected void fireEditingStopped(Object source,
                                  int row,
                                  int column)
Notifies all listeners that have registered interest for notification on this event type. The event instance is created lazily.

Parameters:
source - the source of the event
row - the row index
column - the column index
See Also:
EventListenerList

fireEditingCanceled

protected void fireEditingCanceled(Object source,
                                   int row,
                                   int column)
Notifies all listeners that have registered interest for notification on this event type. The event instance is created lazily.

Parameters:
source - the source of the event
row - the row index
column - the column index
See Also:
EventListenerList

getRowHeights

public RowHeights getRowHeights()

createRowHeights

protected RowHeights createRowHeights()

setRowHeights

public void setRowHeights(RowHeights rowHeights)

isScrollRowWhenRowHeightChanges

public boolean isScrollRowWhenRowHeightChanges()
Checks the flag whether a row is scrolled to visible when its height changes.

Returns:
the scrollRowWhenRowHeightChanges flag.

setScrollRowWhenRowHeightChanges

public void setScrollRowWhenRowHeightChanges(boolean scrollRowWhenRowHeightChanges)
Sets the flag if the row should be scrolled to visible when the row height changes.

Parameters:
scrollRowWhenRowHeightChanges - true or false.

createRowAutoScrollingListener

protected RowHeightChangeListener createRowAutoScrollingListener()
Creates the RowHeightChangeListener which will automatically scroll the row then row height changes so that it is outside the visible area.

Returns:
a RowHeightChangeListener.

scrollRowToVisible

public void scrollRowToVisible(int row)
Scroll the row till the row is visible. If possible, it will try to make the row after it and the row before it visible too. By default, we will call TableUtils.ensureRowVisible(javax.swing.JTable,int) method. It will only scroll vertically to the exact location so that the row is fully visible.

This method is called automatically when row height changes. If isScrollRowWhenRowHeightChanges() is true, the row will automatically be scrolled to show the whole row when the height for that row changes. You can subclass it to scroll the table in a different way.

Parameters:
row - the row whose height changes.

setRowHeight

public void setRowHeight(int rowHeight)
Sets the height, in pixels, of all cells to rowHeight, re-validates, and repaints. The height of the cells will be equal to the row height minus the row margin.

Overrides:
setRowHeight in class JTable
Parameters:
rowHeight - new row height
Throws:
IllegalArgumentException - if rowHeight is less than 1 description: The height of the specified row.
See Also:
getRowHeight(int)

isBatchProcessing

protected boolean isBatchProcessing()
Checks if it is in batch processing. If yes, we should delay doLayout call to the end.

Returns:
true or false.

setBatchProcessing

protected void setBatchProcessing(boolean batchProcessing)
Sets to batch processing. This method should be used only when you want to expand or collapse several rows and you only want to doLayout once at the end.

Parameters:
batchProcessing - true or false.

setRowHeight

public void setRowHeight(int row,
                         int rowHeight)
Sets the height for row to rowHeight, re-validates, and repaints. The height of the cells in this row will be equal to the row height minus the row margin.

Overrides:
setRowHeight in class JTable
Parameters:
row - the row whose height is being changed
rowHeight - new row height, in pixels
Throws:
IllegalArgumentException - if rowHeight is less than 1 description: The height in pixels of the cells in row

calculateAutoResizedRowHeights

protected void calculateAutoResizedRowHeights(int firstRow,
                                              int lastRow)

calculateAutoResizedRowHeights

protected void calculateAutoResizedRowHeights()

calculateRowHeight

protected int calculateRowHeight(int row)
The method calculates the height for the row based on the content in the row.

The method will not change the row height of the designated row.

Parameters:
row - the row to be calculated
Returns:
new height appropriate for the row.

isRowHeightChanged

protected boolean isRowHeightChanged(int row,
                                     int newHeight)
The method will check if the new height is different with current height. The method is called by TableUtils.autoResizeRow(javax.swing.JTable, int, int).

Parameters:
row - the row to be checked
newHeight - new height of the row, most likely from calculateRowHeight(int)
Returns:
True if current row height is not the same with the new height. Otherwise false.

getRowHeight

public int getRowHeight(int row)
Overrides:
getRowHeight in class JTable

rowAtPoint

public int rowAtPoint(Point point)
Returns the index of the row that point lies in, or -1 if the result is not in the range [0, getRowCount()-1].

Overrides:
rowAtPoint in class JTable
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]
See Also:
JTable.columnAtPoint(java.awt.Point)

getCellRect

public Rectangle getCellRect(int row,
                             int column,
                             boolean includeSpacing)
Overrides:
getCellRect in class JTable

getEditorCellRect

public Rectangle getEditorCellRect(int rowIndex,
                                   int columnIndex)
In TreeTable and HierarchicalTable case, the cell rect for cell editor should consider the +/- icon size so the cell editor doesn't cover the +/- icon. In order to do it, we introduce EditorCellRect concept. By default, it is same as getCellRect(rowIndex, columnIndex, false). TreeTable and HierarchicalTable will override it to provide a different rect for cell editor.

Parameters:
rowIndex - the row index.
columnIndex - the column index
Returns:
the cell rect for the cell editor.

createDefaultColumnsFromModel

public void createDefaultColumnsFromModel()
Overrides:
createDefaultColumnsFromModel in class JTable

setKeepRowHeights

public void setKeepRowHeights(boolean keepRowHeights)
Set if you want to keep row heights after table events, such as sorting and filtering.

See isKeepRowHeights()

Parameters:
keepRowHeights - the flag that if the table will keep the row heights

isKeepRowHeights

public boolean isKeepRowHeights()
Get if you want to keep row heights after table events, such as sorting and filtering.

If you set this flag to true, you could keep row heights after sorting and filtering. However, it will hit the performance a little bit. So if you have a large table and don't care about the row heights, you could set this flag to false.

The default value is true.

Returns:
the flag that if the table will keep the row heights.

saveTableRowSettings

protected void saveTableRowSettings(boolean invokeOutside)
To save row heights and selections before you do some big work, like firing table data change event.

Please always make a pair call with loadTableRowSettings(boolean).

Parameters:
invokeOutside - always TRUE if you want to call this method explicitly. We will call this method with FALSE internally.

loadTableRowSettings

protected void loadTableRowSettings(boolean invokeOutside)
To load row heights and selections after you do some big work, like firing table data change event.

Please always make a pair call with saveTableRowSettings(boolean).

Parameters:
invokeOutside - always TRUE if you want to call this method explicitly. We will call this method with FALSE internally.

indexChanged

public void indexChanged(IndexChangeEvent event)
Called whenever the table model wrapper is going to have some change. So far we have index changing and index changed events.

Specified by:
indexChanged in interface IndexChangeListener
Parameters:
event - the table model wrapper event

tableChanged

public void tableChanged(TableModelEvent e)
Invoked when this table's TableModel generates a TableModelEvent. The TableModelEvent should be constructed in the coordinate system of the model; the appropriate mapping to the view coordinate system is performed by this JTable when it receives the event.

Application code will not use these methods explicitly, they are used internally by JTable.

Specified by:
tableChanged in interface TableModelListener
Overrides:
tableChanged in class JTable

createDefaultSelectionModel

protected ListSelectionModel createDefaultSelectionModel()
Overrides:
createDefaultSelectionModel in class JTable

isRowAutoResizes

public boolean isRowAutoResizes()
Checks if row automatically resizes with the cells preferred heights.

Returns:
true if it automatically resizes. Otherwise, false.

setRowAutoResizes

public void setRowAutoResizes(boolean rowAutoResizes)
Sets the rowAutoResizes attribute.

Parameters:
rowAutoResizes - true to enable rowAutoResizes. Otherwise false.

setSortTableHeaderRenderer

protected void setSortTableHeaderRenderer()
JideTable allows you to have multiple lines in table header. However this feature is turned off by default. If you want to have this feature, you can do this.

 JideTable table = new JideTable(model){
     protected void initTable() {
         super.initTable();
         setSortTableHeaderRenderer();
     }
 

protected JTableHeader createDefaultTableHeader() { return new JTableHeader(columnModel); } };

Now if you have a column name that has "\n" in it, it will split the text into multiple lines.


createSortHeaderRenderer

protected SortTableHeaderRenderer createSortHeaderRenderer()
Creates the header renderer. By default SortTableHeaderRenderer will be used. Subclass can override this method to create their own header renderer.

Returns:
the header renderer.

isNonContiguousCellSelection

public boolean isNonContiguousCellSelection()
Checks if the table selection model allows non-contiguous cell selection.

Returns:
true if the table selection model allows non-contiguous cell selection. If so, you can call getTableSelectionModel() to get the selection model and add listener to it. If false, getTableSelectionModel() will return null.

setNonContiguousCellSelection

public void setNonContiguousCellSelection(boolean nonContiguousCellSelection)
Sets the attribute of nonContiguousCellSelection. By default it's false.

Parameters:
nonContiguousCellSelection - true to enable non-contiguous cell selection.

setRowSelectionAllowed

public void setRowSelectionAllowed(boolean rowSelectionAllowed)
Description copied from interface: TableAdapter
Sets whether the rows can be selected.

Specified by:
setRowSelectionAllowed in interface TableAdapter
Overrides:
setRowSelectionAllowed in class JTable
Parameters:
rowSelectionAllowed - true if it will allow row selection

setColumnSelectionAllowed

public void setColumnSelectionAllowed(boolean columnSelectionAllowed)
Description copied from interface: TableAdapter
Sets whether the columns can be selected.

Specified by:
setColumnSelectionAllowed in interface TableAdapter
Overrides:
setColumnSelectionAllowed in class JTable
Parameters:
columnSelectionAllowed - true if it will allow column selection

createDefaultTableSelectionModel

public void createDefaultTableSelectionModel()
Creates a default TableSelectionModel.


setTableSelectionModel

public void setTableSelectionModel(TableSelectionModel tableSelectionModel)
Sets a new TableSelectionModel.

Parameters:
tableSelectionModel - the new TableSelectionModel.

getTableSelectionModel

public TableSelectionModel getTableSelectionModel()
Gets the table selection model. It will return a valid value only when isNonContiguousCellSelection() return true.

Returns:
the TableSelectionModel.

getSelectedRows

public int[] getSelectedRows()
Description copied from interface: TableAdapter
Returns the indices of all selected rows.

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

getSelectedColumns

public int[] getSelectedColumns()
Description copied from interface: TableAdapter
Returns the indices of all selected columns.

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

getSelectedRow

public int getSelectedRow()
Description copied from interface: TableAdapter
Returns the index of the first selected row, -1 if no row is selected.

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

getSelectedColumn

public int getSelectedColumn()
Description copied from interface: TableAdapter
Returns the index of the first selected column, -1 if no column is selected.

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

getSelectedRowCount

public int getSelectedRowCount()
Description copied from interface: TableAdapter
Returns the number of selected rows.

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

getSelectedColumnCount

public int getSelectedColumnCount()
Description copied from interface: TableAdapter
Returns the number of selected columns.

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

isRowSelected

public boolean isRowSelected(int row)
Description copied from interface: TableAdapter
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
Overrides:
isRowSelected in class JTable
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)
Description copied from interface: TableAdapter
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
Overrides:
isColumnSelected in class JTable
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)
Description copied from interface: TableAdapter
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
Overrides:
isCellSelected in class JTable
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

isCalculateRowHeightsOnWidthChange

public boolean isCalculateRowHeightsOnWidthChange()
Get the flag indicating if JideTable should calculate row heights if column width is changed.

This flag will only take effect when isRowAutoResizes() returns true.

The default value of this flag is true.

Returns:
true if JideTable will calculate row heights if column width is changed. Otherwise false.

setCalculateRowHeightsOnWidthChange

public void setCalculateRowHeightsOnWidthChange(boolean calculateRowHeightsOnWidthChange)
Set the flag indicating if JideTable should calculate row heights if column width is changed.

Parameters:
calculateRowHeightsOnWidthChange - the flag

isAlwaysRequestFocusForEditor

public boolean isAlwaysRequestFocusForEditor()
Get the flag indicating if JideTable should always request focus for cell editor.

The default value for this flag is false, which improves the performance.

If you want the cell editor get focus immediately so that Add-ons like IntelliHint can take effect right after you press a key to start editing.

Returns:
the flag.

setAlwaysRequestFocusForEditor

public void setAlwaysRequestFocusForEditor(boolean alwaysRequestFocusForEditor)
Set the flag indicating if JideTable should always request focus for cell editor.

Parameters:
alwaysRequestFocusForEditor - the flag

isClearPropertyAtStructureChange

public boolean isClearPropertyAtStructureChange()
Get the flag indicating if JideTable should clear properties for table column orders.

By default, the value is true. However, for some special table like AggregateTable, we do need keep the status even if table structure change event is fired. In that case, we will set it to false.

Returns:
the flag

setClearPropertyAtStructureChange

public void setClearPropertyAtStructureChange(boolean clearPropertyAtStructureChange)
Set the flag indicating if JideTable should clear properties for table column orders.

Parameters:
clearPropertyAtStructureChange - the flag

paintCellOverlay

public void paintCellOverlay(Graphics g,
                             Component component,
                             int row,
                             int column,
                             Rectangle cellRect)
Paints the cell overlay.

Parameters:
g - the Graphics
component - the component
row - the row index
column - the column index
cellRect - the cell rectangle of the cell at the specified row index and column index.

isEnableIgnored

public boolean isEnableIgnored()
Get the flag indicating if the cell will be painted with normal text color even the table is disabled. JTable doesn't respect enabled flag. There is a bug reported on it at http://bugs.sun.com/view_bug.do?bug_id=4113508 but Sun probably will not fix it. We fixed in JideTable. However if you prefer to keep the old JTable behavior, you can call setEnableIgnored(boolean) and set it to true.

The default value is false.

Returns:
the flag.

setEnableIgnored

public void setEnableIgnored(boolean enableIgnored)
Set the flag indicating if the cell will be painted with the normal text color even the table is disabled.

Parameters:
enableIgnored - the flag

editCellAt

public boolean editCellAt(int row,
                          int column,
                          EventObject e)
Overrides:
editCellAt in class JTable

isValidCellEditingKey

protected boolean isValidCellEditingKey(KeyEvent keyEvent)
Checks if the key event is a valid keystroke to start cell editing. Subclass can override it. Here is the default implementation.
 if (keyEvent.getKeyCode() == KeyEvent.VK_UNDEFINED) {
     return false;
 }
 else if ((keyEvent.getKeyCode() >= KeyEvent.VK_COMMA && keyEvent.getKeyCode() <= KeyEvent.VK_DIVIDE)
         && ((keyEvent.getModifiers() & KeyEvent.ALT_MASK) != 0 || (keyEvent.getModifiers() & KeyEvent.CTRL_MASK)
 != 0 || (keyEvent.getModifiers() & KeyEvent.META_MASK) != 0)) {
     return false;
 }
 else if ((keyEvent.getKeyCode() < KeyEvent.VK_COMMA || keyEvent.getKeyCode() > KeyEvent.VK_DIVIDE) &&
 (keyEvent.getKeyCode() != KeyEvent.VK_BACK_QUOTE && keyEvent.getKeyCode() != KeyEvent.VK_QUOTE &&
 keyEvent.getKeyCode() != KeyEvent.VK_SPACE)) {
     return false;
 }
 return true;
 

Parameters:
keyEvent - the key event
Returns:
true if it is a valid key. Otherwise false.

clearSelectionPermanently

public void clearSelectionPermanently()
Clear the selections permanently without being restored later on.


clearSelection

public void clearSelection()
Overrides:
clearSelection in class JTable

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
Overrides:
changeSelection in class JTable
Parameters:
rowIndex - affects the selection at row
columnIndex - affects the selection at column
toggle - see description above
extend - if true, extend the current selection

addColumn

public void addColumn(TableColumn column)
Overrides this method to skip the column that is being added when the column was hidden earlier by TableColumnChooser.hideColumn(javax.swing.JTable, int) method.

Overrides:
addColumn in class JTable
Parameters:
column - the TableColumn to be added.

adjustSelectionWhenColumnMoved

public void adjustSelectionWhenColumnMoved(int column,
                                           int targetColumn)
Usually you don't need to call this method. But if you use non-contiguous cell selection feature and use your own TableColumnModel that is created by JTable, you should call this method in TableColumnModel's moveColumn implementation so that the selection can be adjusted when column is moved.

Parameters:
column - the column index
targetColumn - the target column index.

releaseRendererComponent

public void releaseRendererComponent(TableCellRenderer renderer,
                                     int row,
                                     int column,
                                     Component component)

prepareRenderer

public Component prepareRenderer(TableCellRenderer renderer,
                                 int row,
                                 int column)
Overrides:
prepareRenderer in class JTable

getSelectionBackground

public Color getSelectionBackground()
Overrides:
getSelectionBackground in class JTable

isColumnAutoResizable

public boolean isColumnAutoResizable()
Checks if the column is auto-resizable. If the column is auto-resizable, user can double click on the grid line on table header and the table column will automatically resize to fit in the content of all the cells in that column.

Returns:
true if the column is auto-resizable.

setColumnAutoResizable

public void setColumnAutoResizable(boolean resizable)
Enable or disable the column auto-resizable. Please note, you need to call this method again if you change your table header as this method call will install a listener on the table header if resizable is true.

Parameters:
resizable - true to make column auto-resizable.

isColumnResizable

public boolean isColumnResizable()
Checks if the column is resizable by dragging the vertical grid line.

Returns:
true if the column is resizable by dragging the vertical grid line.

setColumnResizable

public void setColumnResizable(boolean resizable)
Enable or disable the column resizable. If column is resizable, user can drag the vertical grid line to resize the column.

Parameters:
resizable - true to make column resizable.

isRowResizable

public boolean isRowResizable()
Checks if the row is resizable by dragging the horizontal grid line.

Returns:
true if the row is resizable by dragging the horizontal grid line.

setRowResizable

public void setRowResizable(boolean resizable)
Enable or disable the row resizable. If row is resizable, user can drag the horizontal grid line to resize the row.

Parameters:
resizable - true to make row resizable.

selectAll

public void selectAll()
Overrides:
selectAll in class JTable

getToolTipText

public String getToolTipText(MouseEvent event)
Overrides:
getToolTipText in class JTable

isTablePrinting

public boolean isTablePrinting()
Checks if the table is printing.

Returns:
true if the table is printing.

setTablePrinting

public void setTablePrinting(boolean tablePrinting)
Sets the table as printing. If the table is printing, prepareRenderer method will not consider the cell selection.

Parameters:
tablePrinting - true to indicate the table is being printed.

isVariousRowHeights

public boolean isVariousRowHeights()
Is the table has various row height on each row. There is no setter for this property. The only way to change it is to override to return a different value. We did this way because we don't think a table should by nature either has various row heights or the same row heights. So you should know beforehand if the table has the same or different row heights thus overriding is a better way.

For example, in the case of HierarchicalTable, we override it to always return true.

Returns:
true if isRowAutoResizes() is true.

setVariousRowHeights

public void setVariousRowHeights(boolean variousRowHeights)
Sets variousRowHeights. Calling the method will change the heights of visible rows immediately if necessary. If variousRowHeights is false, all rows will have the same row height. This is used when user tries to resize a row when setRowResizable(true) is called. If variousRowHeights is false, we will make all rows the same height after user resizes a row.

Parameters:
variousRowHeights - true or false

getTransferHandler

public TransferHandler getTransferHandler()
Overrides this method to provide our own TransferHandler if isNonContiguousCellSelection() is true only if the original TransferHandler is an instance of UIResource. So you set your own TransferHandler (which is usually not an instance of UIResource), yours will be used.

Overrides:
getTransferHandler in class JComponent
Returns:
the TransferHandler.

isSelectInsertedRows

public boolean isSelectInsertedRows()
Returns the selectInsertedRows flag. If true, the newly inserted rows, if it is just above the existing selected row, will be selected automatically. By default, this is true.

Returns:
true or false.

setSelectInsertedRows

public void setSelectInsertedRows(boolean selectInsertedRows)
Sets the selectInsertedRow flag. If true, the newly inserted row, if it is just above the existing selected row, will be selected automatically. By default, this is true.

Parameters:
selectInsertedRows - true or false.

isClearSelectionOnTableDataChanges

public boolean isClearSelectionOnTableDataChanges()
Checks if the selection should be cleared when tableDataChanged event is fired.

Returns:
true if the selection is cleared when the tableDataChanged event is fired. Otherwise, false. Default is false.

setClearSelectionOnTableDataChanges

public void setClearSelectionOnTableDataChanges(boolean clearSelectionOnTableDataChanges)
Sets the clearSelectionOnTableDataChanges attribute.

Parameters:
clearSelectionOnTableDataChanges - true to clear selection when table data changed event is fired.

valueChanged

public void valueChanged(ListSelectionEvent e)
Specified by:
valueChanged in interface ListSelectionListener
Overrides:
valueChanged in class JTable

setClickCountToStart

public void setClickCountToStart(int count)
Specifies the number of clicks needed to start editing.

Parameters:
count - an int specifying the number of clicks needed to start editing
See Also:
getClickCountToStart()

getClickCountToStart

public int getClickCountToStart()
Returns the number of clicks needed to start editing.

Returns:
the number of clicks needed to start editing

getGridColor

public Color getGridColor(int row)
Gets the grid line color for each row.

Parameters:
row - the row index.
Returns:
the color for that row. Null if using the default grid color.

getVerticalGridColor

public Color getVerticalGridColor(int column)
Gets the grid line color for each column.

Parameters:
column - the column index.
Returns:
the color for that row. Null if using the default grid color.

getTableColumnWidthKeeper

public TableColumnWidthKeeper getTableColumnWidthKeeper()

setTableColumnWidthKeeper

public void setTableColumnWidthKeeper(TableColumnWidthKeeper tableColumnWidthKeeper)

setPreferredSize

public void setPreferredSize(Dimension preferredSize)
Overrides:
setPreferredSize in class JComponent

isAutoStartCellEditing

public boolean isAutoStartCellEditing()
Checks if the navigation key stroke will start cell editing. By default the navigation key strokes are tab and enter keys.

Returns:
true or false.

setAutoStartCellEditing

public void setAutoStartCellEditing(boolean autoStartCellEditing)
Sets the flag if the navigation key stroke will start cell editing.

Parameters:
autoStartCellEditing - true or false.

isAutoStartCellEditingKey

protected boolean isAutoStartCellEditingKey(KeyStroke ks)
Checks if the key stroke will trigger the cell editing. By default, we allow tab key and enter key to start cell editing automatically if isAutoStartCellEditing() is true.

Parameters:
ks - the key stroke
Returns:
true or false.

addNotify

public void addNotify()
Overrides:
addNotify in class JTable

removeNotify

public void removeNotify()
Overrides:
removeNotify in class JTable

removeEditor

public void removeEditor()
Override to regain focus on JTable when the AbstractComboBox's popup panel has focus. This special case is skipped by removeEditor method in JTable.

Overrides:
removeEditor in class JTable

isAutoSelectTextWhenStartsEditing

public boolean isAutoSelectTextWhenStartsEditing()
Checks if the text in the cell editor will be selected when cell starts editing. For example, if the cell editor is a JTextField, we will select the text when user presses any key to start cell editing. It will work if the cell editor component is JTextComponent, JComboBox, AbstractComboBox or JSpinner. For all other custom cell editors, you would need to override getTextComponentForEditorComponent(java.awt.Component) to return the JTextComponent that you would like the text to be selected.

Default is true.

Returns:
true to select the cell content when starts cell editing. Otherwise false.

setAutoSelectTextWhenStartsEditing

public void setAutoSelectTextWhenStartsEditing(boolean autoSelectTextWhenStartsEditing)
Sets the flag if the text in the cell editor will be selected when starts editing. For example, if the cell editor is a JTextField, we will select the text when user presses any key to start cell editing. It will work if the cell editor component is JTextComponent, JComboBox, AbstractComboBox or JSpinner. For all other custom cell editors, you would need to override getTextComponentForEditorComponent(java.awt.Component) to return the JTextComponent that you would like the text to be selected.

Default is true.

Parameters:
autoSelectTextWhenStartsEditing - true or false.

convertRowIndexToView

public int convertRowIndexToView(int modelRowIndex)
Overrides this methods so that it is available for pre-JDK6 environment. For JDK6, this method will call super.convertRowIndexToView(modelRowIndex). For pre-JDK, it will simply return modelRowIndex. We do so because we want to make sure we still get the correct row index in case user uses the JTable's built-in sorting feature in JDK. In fact, since we have sorting feature already in JIDE Grids and is faster and a lot of more flexible than JTable's built-in sorting, we suggest you to use our sorting instead.

Please note, this method has nothing to do with our sorting and filtering if you want to convert the row index. The correct way to convert row index is TableModelWrapperUtils's getRowAt method.

Overrides:
convertRowIndexToView in class JTable
Parameters:
modelRowIndex - the model row index.
Returns:
the view row index.

convertRowIndexToModel

public int convertRowIndexToModel(int viewRowIndex)
Overrides this methods so that it is available for pre-JDK6 environment. For JDK6, this method will call super.convertRowIndexToModel(modelRowIndex). For pre-JDK, it will simply return viewRowIndex. We do so because we want to make sure we still get the correct row index in case user uses the JTable's built-in sorting feature in JDK. In fact, since we have sorting feature already in JIDE Grids and is faster and a lot of more flexible than JTable's built-in sorting, we suggest you to use our sorting instead.

Please note, this method has nothing to do with our sorting and filtering if you want to convert the row index. The correct way to convert row index is TableModelWrapperUtils's getActualRowAt method.

Overrides:
convertRowIndexToModel in class JTable
Parameters:
viewRowIndex - the view row index.
Returns:
the model row index.

alwaysCalculateCellRect

public boolean alwaysCalculateCellRect()
A boolean flag to determine if the rect should always be calculated when painting the grid line and cells. If false, it will calculate the rect for the first column once and then add the column width to determine the next column cell rect. It returns false in JideTable but subclass can return true (such as in TreeTable and HierarchicalTable case).

Returns:
false by default.

isCellContentVisible

public boolean isCellContentVisible()
Checks if the table cell content will be painted.

Returns:
true if the table cell content will be painted. Otherwise false.

setCellContentVisible

public void setCellContentVisible(boolean cellContentVisible)
Sets the cell content visible or invisible. The reason we need this method is because we want to prevent the cell from being displayed in certain cases. For example, when the table is being scrolled, we don't want the cells being displayed when they are quickly scrolled over. Only when the scroll is done, we show the cells.

Parameters:
cellContentVisible - true or false.

configureEnclosingScrollPaneExplicitly

public void configureEnclosingScrollPaneExplicitly()

columnAdded

public void columnAdded(TableColumnModelEvent e)
Specified by:
columnAdded in interface TableColumnModelListener
Overrides:
columnAdded in class JTable

columnRemoved

public void columnRemoved(TableColumnModelEvent e)
Specified by:
columnRemoved in interface TableColumnModelListener
Overrides:
columnRemoved in class JTable

columnMoved

public void columnMoved(TableColumnModelEvent e)
Specified by:
columnMoved in interface TableColumnModelListener
Overrides:
columnMoved in class JTable

setEnabled

public void setEnabled(boolean enabled)
Overrides:
setEnabled in class JComponent

getEditorAutoCompletionMode

public int getEditorAutoCompletionMode()
Gets the editor auto-completion mode.

Returns:
the editor auto-completion mode.

setEditorAutoCompletionMode

public void setEditorAutoCompletionMode(int editorAutoCompletionMode)
Sets the editor auto-completion mode. JideTable has a feature to enable the cell editor auto-completion. When it is turned on, typing a cell editor that has a text field will automatically complete the rest of the values based on the existing values from the same column (or the same row, or the whole table).

Parameters:
editorAutoCompletionMode - the editor auto-completion mode.

isCellFocused

protected boolean isCellFocused(int rowIndex,
                                int columnIndex)
Check if the cell is a focused cell inside the table.

Parameters:
rowIndex - the row index of the cell
columnIndex - the column index of the cell
Returns:
true if the cell is focues. Otherwise false.

JIDE 2.9.5