javax.swing
Class JTable

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JTable
All Implemented Interfaces:
Accessible, CellEditorListener, EventListener, java.awt.image.ImageObserver, ListSelectionListener, MenuContainer, Scrollable, Serializable, TableColumnModelListener, TableModelListener

public class JTable
extends JComponent
implements TableModelListener, Scrollable, TableColumnModelListener, ListSelectionListener, CellEditorListener, Accessible

Safe:

See Also:
Serialized Form

Field Summary
static int AUTO_RESIZE_ALL_COLUMNS
          Enabled: During all resize operations, proportionately resize all columns.
static int AUTO_RESIZE_LAST_COLUMN
          Enabled: During all resize operations, apply adjustments to the last column only.
static int AUTO_RESIZE_NEXT_COLUMN
          Enabled: When a column is adjusted in the UI, adjust the next column the opposite way.
static int AUTO_RESIZE_OFF
          Enabled: Do not adjust column widths automatically; use a scrollbar.
static int AUTO_RESIZE_SUBSEQUENT_COLUMNS
          Enabled: During UI adjustment, change subsequent columns to preserve the total width; this is the default behavior.
protected  boolean autoCreateColumnsFromModel
          The table will query the TableModel to build the default set of columns if this is true.
protected  int autoResizeMode
          Determines if the table automatically resizes the width of the table's columns to take up the entire width of the table, and how it does the resizing.
protected  javax.swing.table.TableCellEditor cellEditor
          The object that overwrites the screen real estate occupied by the current cell and allows the user to change its contents.
protected  boolean cellSelectionEnabled
          Obsolete as of Java 2 platform v1.3.
protected  javax.swing.table.TableColumnModel columnModel
          The TableColumnModel of the table.
protected  javax.swing.table.TableModel dataModel
          The TableModel of the table.
protected  Hashtable defaultEditorsByColumnClass
          A table of objects that display and edit the contents of a cell, indexed by class as declared in getColumnClass in the TableModel interface.
protected  Hashtable defaultRenderersByColumnClass
          A table of objects that display the contents of a cell, indexed by class as declared in getColumnClass in the TableModel interface.
private  boolean dragEnabled
           
protected  int editingColumn
          Identifies the column of the cell being edited.
protected  int editingRow
          Identifies the row of the cell being edited.
protected  Component editorComp
          If editing, the Component that is handling the editing.
private  java.beans.PropertyChangeListener editorRemover
           
protected  Color gridColor
          The color of the grid.
protected  Dimension preferredViewportSize
          Used by the Scrollable interface to determine the initial visible area.
protected  int rowHeight
          The height in pixels of each row in the table.
protected  int rowMargin
          The height in pixels of the margin between the cells in each row.
private  SizeSequence rowModel
           
protected  boolean rowSelectionAllowed
          True if row selection is allowed in this table.
protected  Color selectionBackground
          The background color of selected cells.
protected  Color selectionForeground
          The foreground color of selected cells.
protected  ListSelectionModel selectionModel
          The ListSelectionModel of the table, used to keep track of row selections.
protected  boolean showHorizontalLines
          The table draws horizontal lines between cells if showHorizontalLines is true.
protected  boolean showVerticalLines
          The table draws vertical lines between cells if showVerticalLines is true.
private  boolean surrendersFocusOnKeystroke
           
protected  javax.swing.table.JTableHeader tableHeader
          The TableHeader working with the table.
private static String uiClassID
           
 
Fields inherited from class javax.swing.JComponent
_bounds, accessibleContext, listenerList, paintingChild, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Container
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
JTable()
          Enabled: Constructs a default JTable that is initialized with a default data model, a default column model, and a default selection model.
JTable(int numRows, int numColumns)
          Enabled: Constructs a JTable with numRows and numColumns of empty cells using DefaultTableModel.
JTable(Object[][] rowData, Object[] columnNames)
          Enabled: Constructs a JTable to display the values in the two dimensional array, rowData, with column names, columnNames.
JTable(javax.swing.table.TableModel dm)
          Enabled: Constructs a JTable that is initialized with dm as the data model, a default column model, and a default selection model.
JTable(javax.swing.table.TableModel dm, javax.swing.table.TableColumnModel cm)
          Enabled: Constructs a JTable that is initialized with dm as the data model, cm as the column model, and a default selection model.
JTable(javax.swing.table.TableModel dm, javax.swing.table.TableColumnModel cm, ListSelectionModel sm)
          Enabled: Constructs a JTable that is initialized with dm as the data model, cm as the column model, and sm as the selection model.
JTable(Vector rowData, Vector columnNames)
          Enabled: Constructs a JTable to display the values in the Vector of Vectors, rowData, with column names, columnNames.
 
Method Summary
private  void accommodateDelta(int resizingColumnIndex, int delta)
           
 void addColumn(javax.swing.table.TableColumn aColumn)
          Enabled: Appends aColumn to the end of the array of columns held by this JTable's column model.
 void addColumnSelectionInterval(int index0, int index1)
          Enabled: Adds the columns from index0 to index1, inclusive, to the current selection.
 void addNotify()
          Suppressed: Calls the configureEnclosingScrollPane method.
 void addRowSelectionInterval(int index0, int index1)
          Enabled: Adds the rows from index0 to index1, inclusive, to the current selection.
private  void adjustSizes(long target, javax.swing.JTable.Resizable2 r, boolean limitToRange)
           
private  void adjustSizes(long target, javax.swing.JTable.Resizable3 r, boolean inverse)
           
private  int boundColumn(int col)
           
private  int boundRow(int row)
           
 void changeSelection(int rowIndex, int columnIndex, boolean toggle, boolean extend)
          Enabled: Updates the selection models of the table, depending on the state of the two flags: toggle and extend.
private  void changeSelectionModel(ListSelectionModel sm, int index, boolean toggle, boolean extend, boolean selected)
           
 void clearSelection()
          Enabled: Deselects all selected columns and rows.
 void columnAdded(TableColumnModelEvent e)
          Suppressed: Invoked when a column is added to the table column model.
 int columnAtPoint(Point point)
          Enabled: Returns the index of the column that point lies in, or -1 if the result is not in the range [0, getColumnCount()-1].
 void columnMarginChanged(ChangeEvent e)
          Suppressed: Invoked when a column is moved due to a margin change.
 void columnMoved(TableColumnModelEvent e)
          Suppressed: Invoked when a column is repositioned.
 void columnRemoved(TableColumnModelEvent e)
          Suppressed: Invoked when a column is removed from the table column model.
 void columnSelectionChanged(ListSelectionEvent e)
          Suppressed: Invoked when the selection model of the TableColumnModel is changed.
(package private)  void compWriteObjectNotify()
           
protected  void configureEnclosingScrollPane()
          If this JTable is the viewportView of an enclosing JScrollPane (the usual situation), configure this ScrollPane by, amongst other things, installing the table's tableHeader as the columnHeaderView of the scroll pane.
 int convertColumnIndexToModel(int viewColumnIndex)
          Enabled: Maps the index of the column in the view at viewColumnIndex to the index of the column in the table model.
 int convertColumnIndexToView(int modelColumnIndex)
          Enabled: Maps the index of the column in the table model at modelColumnIndex to the index of the column in the view.
protected  javax.swing.table.TableColumnModel createDefaultColumnModel()
          Returns the default column model object, which is a DefaultTableColumnModel.
 void createDefaultColumnsFromModel()
          Enabled: Creates default columns for the table from the data model using the getColumnCount method defined in the TableModel interface.
protected  javax.swing.table.TableModel createDefaultDataModel()
          Returns the default table model object, which is a DefaultTableModel.
protected  void createDefaultEditors()
          Creates default cell editors for objects, numbers, and boolean values.
protected  void createDefaultRenderers()
          Creates default cell renderers for objects, numbers, doubles, dates, booleans, and icons.
protected  ListSelectionModel createDefaultSelectionModel()
          Returns the default selection model object, which is a DefaultListSelectionModel.
protected  javax.swing.table.JTableHeader createDefaultTableHeader()
          Returns the default table header object, which is a JTableHeader.
static JScrollPane createScrollPaneForTable(JTable aTable)
          Deprecated. As of Swing version 1.0.2, replaced by new JScrollPane(aTable).
 void doLayout()
          Enabled: Causes this table to lay out its rows and columns.
 boolean editCellAt(int row, int column)
          Enabled: Programmatically starts editing the cell at row and column, if the cell is editable.
 boolean editCellAt(int row, int column, EventObject e)
          Enabled: Programmatically starts editing the cell at row and column, if the cell is editable.
 void editingCanceled(ChangeEvent e)
          Suppressed: Invoked when editing is canceled.
 void editingStopped(ChangeEvent e)
          Suppressed: Invoked when editing is finished.
 AccessibleContext getAccessibleContext()
          Suppressed: Gets the AccessibleContext associated with this JTable.
 boolean getAutoCreateColumnsFromModel()
          Enabled: Determines whether the table will create default columns from the model.
 int getAutoResizeMode()
          Enabled: Returns the auto resize mode of the table.
 javax.swing.table.TableCellEditor getCellEditor()
          Enabled: Returns the cell editor.
 javax.swing.table.TableCellEditor getCellEditor(int row, int column)
          Enabled: Returns an appropriate editor for the cell specified by row and column.
 Rectangle getCellRect(int row, int column, boolean includeSpacing)
          Enabled: Returns a rectangle for the cell that lies at the intersection of row and column.
 javax.swing.table.TableCellRenderer getCellRenderer(int row, int column)
          Enabled: Returns an appropriate renderer for the cell specified by this row and column.
 boolean getCellSelectionEnabled()
          Enabled: Returns true if both row and column selection models are enabled.
 javax.swing.table.TableColumn getColumn(Object identifier)
          Enabled: Returns the TableColumn object for the column in the table whose identifier is equal to identifier, when compared using equals.
 Class getColumnClass(int column)
          Enabled: Returns the type of the column appearing in the view at column position column.
 int getColumnCount()
          Enabled: Returns the number of columns in the column model.
 javax.swing.table.TableColumnModel getColumnModel()
          Enabled: Returns the TableColumnModel that contains all column information of this table.
 String getColumnName(int column)
          Enabled: Returns the name of the column appearing in the view at column position column.
 boolean getColumnSelectionAllowed()
          Enabled: Returns true if columns can be selected.
 javax.swing.table.TableCellEditor getDefaultEditor(Class columnClass)
          Enabled: Returns the editor to be used when no editor has been set in a TableColumn.
 javax.swing.table.TableCellRenderer getDefaultRenderer(Class columnClass)
          Enabled: Returns the cell renderer to be used when no renderer has been set in a TableColumn.
 boolean getDragEnabled()
          Enabled: Gets the value of the dragEnabled property.
 int getEditingColumn()
          Enabled: Returns the index of the column that contains the cell currently being edited.
 int getEditingRow()
          Enabled: Returns the index of the row that contains the cell currently being edited.
 Component getEditorComponent()
          Enabled: Returns the component that is handling the editing session.
 Color getGridColor()
          Enabled: Returns the color used to draw grid lines.
 Dimension getIntercellSpacing()
          Enabled: Returns the horizontal and vertical space between cells.
 javax.swing.table.TableModel getModel()
          Enabled: Returns the TableModel that provides the data displayed by this JTable.
 Dimension getPreferredScrollableViewportSize()
          Enabled: Returns the preferred size of the viewport for this table.
private  javax.swing.table.TableColumn getResizingColumn()
           
 int getRowCount()
          Enabled: Returns the number of rows in this table's model.
 int getRowHeight()
          Enabled: Returns the height of a table row, in pixels.
 int getRowHeight(int row)
          Enabled: Returns the height, in pixels, of the cells in row.
 int getRowMargin()
          Enabled: Gets the amount of empty space, in pixels, between cells.
private  SizeSequence getRowModel()
           
 boolean getRowSelectionAllowed()
          Enabled: Returns true if rows can be selected.
 int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction)
          Enabled: Returns visibleRect.height or visibleRect.width, depending on this table's orientation.
 boolean getScrollableTracksViewportHeight()
          Enabled: Returns false to indicate that the height of the viewport does not determine the height of the table.
 boolean getScrollableTracksViewportWidth()
          Enabled: Returns false if autoResizeMode is set to AUTO_RESIZE_OFF, which indicates that the width of the viewport does not determine the width of the table.
 int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction)
          Enabled: Returns the scroll increment (in pixels) that completely exposes one new row or column (depending on the orientation).
 int getSelectedColumn()
          Enabled: Returns the index of the first selected column, -1 if no column is selected.
 int getSelectedColumnCount()
          Enabled: Returns the number of selected columns.
 int[] getSelectedColumns()
          Enabled: Returns the indices of all selected columns.
 int getSelectedRow()
          Enabled: Returns the index of the first selected row, -1 if no row is selected.
 int getSelectedRowCount()
          Enabled: Returns the number of selected rows.
 int[] getSelectedRows()
          Enabled: Returns the indices of all selected rows.
 Color getSelectionBackground()
          Enabled: Returns the background color for selected cells.
 Color getSelectionForeground()
          Enabled: Returns the foreground color for selected cells.
 ListSelectionModel getSelectionModel()
          Enabled: Returns the ListSelectionModel that is used to maintain row selection state.
 boolean getShowHorizontalLines()
          Enabled: Returns true if the table draws horizontal lines between cells, false if it doesn't.
 boolean getShowVerticalLines()
          Enabled: Returns true if the table draws vertical lines between cells, false if it doesn't.
 boolean getSurrendersFocusOnKeystroke()
          Enabled: Returns true if the editor should get the focus when keystrokes cause the editor to be activated
 javax.swing.table.JTableHeader getTableHeader()
          Enabled: Returns the tableHeader used by this JTable.
 String getToolTipText(MouseEvent event)
          Enabled: Overrides JComponent's getToolTipText method in order to allow the renderer's tips to be used if it has text set.
 javax.swing.plaf.TableUI getUI()
          Suppressed: Returns the L&F object that renders this component.
 String getUIClassID()
          Suppressed: Returns the suffix used to construct the name of the L&F class used to render this component.
 Object getValueAt(int row, int column)
          Enabled: Returns the cell value at row and column.
protected  void initializeLocalVars()
          Initializes table properties to their default values.
 boolean isCellEditable(int row, int column)
          Enabled: Returns true if the cell at row and column is editable.
 boolean isCellSelected(int row, int column)
          Enabled: Returns true if the cell at the specified position is selected.
 boolean isColumnSelected(int column)
          Enabled: Returns true if the column at the specified index is selected.
 boolean isEditing()
          Enabled: Returns true if a cell is being edited.
 boolean isRowSelected(int row)
          Enabled: Returns true if the row at the specified index is selected.
private  int limit(int i, int a, int b)
           
 void moveColumn(int column, int targetColumn)
          Enabled: Moves the column column to the position currently occupied by the column targetColumn in the view.
protected  String paramString()
          Returns a string representation of this table.
 Component prepareEditor(javax.swing.table.TableCellEditor editor, int row, int column)
          Enabled: Prepares the editor by querying the data model for the value and selection state of the cell at row, column.
 Component prepareRenderer(javax.swing.table.TableCellRenderer renderer, int row, int column)
          Enabled: Prepares the renderer by querying the data model for the value and selection state of the cell at row, column.
protected  boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed)
          Invoked to process the key bindings for ks as the result of the KeyEvent e.
private  void readObject(ObjectInputStream s)
          We use the ObjectInputStream "registerValidation" callback to update the UI for the entire tree of components after they've all been read in.
 void removeColumn(javax.swing.table.TableColumn aColumn)
          Enabled: Removes aColumn from this JTable's array of columns.
 void removeColumnSelectionInterval(int index0, int index1)
          Enabled: Deselects the columns from index0 to index1, inclusive.
 void removeEditor()
          Enabled: Discards the editor object and frees the real estate it used for cell rendering.
 void removeNotify()
          Suppressed: Calls the unconfigureEnclosingScrollPane method.
 void removeRowSelectionInterval(int index0, int index1)
          Enabled: Deselects the rows from index0 to index1, inclusive.
protected  void resizeAndRepaint()
          Equivalent to revalidate followed by repaint.
 int rowAtPoint(Point point)
          Enabled: Returns the index of the row that point lies in, or -1 if the result is not in the range [0, getRowCount()-1].
 void selectAll()
          Enabled: Selects all rows, columns, and cells in the table.
 void setAutoCreateColumnsFromModel(boolean autoCreateColumnsFromModel)
          Enabled: Sets this table's autoCreateColumnsFromModel flag.
 void setAutoResizeMode(int mode)
          Enabled: Sets the table's auto resize mode when the table is resized.
 void setCellEditor(javax.swing.table.TableCellEditor anEditor)
          Enabled: Sets the cellEditor variable.
 void setCellSelectionEnabled(boolean cellSelectionEnabled)
          Enabled: Sets whether this table allows both a column selection and a row selection to exist simultaneously.
 void setColumnModel(javax.swing.table.TableColumnModel columnModel)
          Enabled: Sets the column model for this table to newModel and registers for listener notifications from the new column model.
 void setColumnSelectionAllowed(boolean columnSelectionAllowed)
          Enabled: Sets whether the columns in this model can be selected.
 void setColumnSelectionInterval(int index0, int index1)
          Enabled: Selects the columns from index0 to index1, inclusive.
 void setDefaultEditor(Class columnClass, javax.swing.table.TableCellEditor editor)
          Enabled: Sets a default cell editor to be used if no editor has been set in a TableColumn.
 void setDefaultRenderer(Class columnClass, javax.swing.table.TableCellRenderer renderer)
          Enabled: Sets a default cell renderer to be used if no renderer has been set in a TableColumn.
 void setDragEnabled(boolean b)
          Enabled: Sets the dragEnabled property, which must be true to enable automatic drag handling (the first part of drag and drop) on this component.
 void setEditingColumn(int aColumn)
          Enabled: Sets the editingColumn variable.
 void setEditingRow(int aRow)
          Enabled: Sets the editingRow variable.
 void setGridColor(Color gridColor)
          Enabled: Sets the color used to draw grid lines to gridColor and redisplays.
 void setIntercellSpacing(Dimension intercellSpacing)
          Enabled: Sets the rowMargin and the columnMargin -- the height and width of the space between cells -- to intercellSpacing.
private  void setLazyEditor(Class c, String s)
           
private  void setLazyRenderer(Class c, String s)
           
private  void setLazyValue(Hashtable h, Class c, String s)
           
 void setModel(javax.swing.table.TableModel dataModel)
          Enabled: Sets the data model for this table to newModel and registers with it for listener notifications from the new data model.
 void setPreferredScrollableViewportSize(Dimension size)
          Enabled: Sets the preferred size of the viewport for this table.
 void setRowHeight(int rowHeight)
          Enabled: Sets the height, in pixels, of all cells to rowHeight, revalidates, and repaints.
 void setRowHeight(int row, int rowHeight)
          Enabled: Sets the height for row to rowHeight, revalidates, and repaints.
 void setRowMargin(int rowMargin)
          Enabled: Sets the amount of empty space between cells in adjacent rows.
 void setRowSelectionAllowed(boolean rowSelectionAllowed)
          Enabled: Sets whether the rows in this model can be selected.
 void setRowSelectionInterval(int index0, int index1)
          Enabled: Selects the rows from index0 to index1, inclusive.
 void setSelectionBackground(Color selectionBackground)
          Enabled: Sets the background color for selected cells.
 void setSelectionForeground(Color selectionForeground)
          Enabled: Sets the foreground color for selected cells.
 void setSelectionMode(int selectionMode)
          Enabled: Sets the table's selection mode to allow only single selections, a single contiguous interval, or multiple intervals.
 void setSelectionModel(ListSelectionModel newModel)
          Enabled: Sets the row selection model for this table to newModel and registers for listener notifications from the new selection model.
 void setShowGrid(boolean showGrid)
          Enabled: Sets whether the table draws grid lines around cells.
 void setShowHorizontalLines(boolean showHorizontalLines)
          Enabled: Sets whether the table draws horizontal lines between cells.
 void setShowVerticalLines(boolean showVerticalLines)
          Enabled: Sets whether the table draws vertical lines between cells.
 void setSurrendersFocusOnKeystroke(boolean surrendersFocusOnKeystroke)
          Suppressed: Sets whether editors in this JTable get the keyboard focus when an editor is activated as a result of the JTable forwarding keyboard events for a cell.
 void setTableHeader(javax.swing.table.JTableHeader tableHeader)
          Enabled: Sets the tableHeader working with this JTable to newHeader.
 void setUI(javax.swing.plaf.TableUI ui)
          Suppressed: Sets the L&F object that renders this component and repaints.
 void setValueAt(Object aValue, int row, int column)
          Enabled: Sets the value for the cell in the table model at row and column.
private  void setWidthsFromPreferredWidths(boolean inverse)
           
 void sizeColumnsToFit(boolean lastColumnOnly)
          Deprecated. As of Swing version 1.0.3, replaced by doLayout().
 void sizeColumnsToFit(int resizingColumn)
          Enabled: Obsolete as of Java 2 platform v1.4.
 void tableChanged(TableModelEvent e)
          Suppressed: Invoked when this table's TableModel generates a TableModelEvent.
private  void tableRowsDeleted(TableModelEvent e)
           
private  void tableRowsInserted(TableModelEvent e)
           
protected  void unconfigureEnclosingScrollPane()
          Reverses the effect of configureEnclosingScrollPane by replacing the columnHeaderView of the enclosing scroll pane with null.
private  void updateSubComponentUI(Object componentShell)
           
 void updateUI()
          Suppressed: Notification from the UIManager that the L&F has changed.
 void valueChanged(ListSelectionEvent e)
          Suppressed: Invoked when the row selection changes -- repaints to show the new selection.
private  int viewIndexForColumn(javax.swing.table.TableColumn aColumn)
           
private  void writeObject(ObjectOutputStream s)
          See readObject() and writeObject() in JComponent for more information about serialization in Swing.
 
Methods inherited from class javax.swing.JComponent
_paintImmediately, addAncestorListener, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, alwaysOnTop, checkIfChildObscuredBySibling, componentInputMapChanged, computeVisibleRect, computeVisibleRect, contains, createToolTip, disable, enable, enableSerialization, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getCreatedDoubleBuffer, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getManagingFocusBackwardTraversalKeys, getManagingFocusForwardTraversalKeys, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getWriteObjCounter, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBindings, processKeyBindingsForAllComponents, processKeyEvent, processMouseMotionEvent, putClientProperty, rectangleIsObscured, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setCreatedDoubleBuffer, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPaintingChild, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, setWriteObjCounter, shouldDebugGraphics, superProcessMouseMotionEvent, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, get, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, iterate, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, size, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, toString, transferFocus, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

uiClassID

private static final String uiClassID
See Also:
getUIClassID(), readObject(java.io.ObjectInputStream)

AUTO_RESIZE_OFF

public static final int AUTO_RESIZE_OFF
Enabled: Do not adjust column widths automatically; use a scrollbar.


AUTO_RESIZE_NEXT_COLUMN

public static final int AUTO_RESIZE_NEXT_COLUMN
Enabled: When a column is adjusted in the UI, adjust the next column the opposite way.


AUTO_RESIZE_SUBSEQUENT_COLUMNS

public static final int AUTO_RESIZE_SUBSEQUENT_COLUMNS
Enabled: During UI adjustment, change subsequent columns to preserve the total width; this is the default behavior.


AUTO_RESIZE_LAST_COLUMN

public static final int AUTO_RESIZE_LAST_COLUMN
Enabled: During all resize operations, apply adjustments to the last column only.


AUTO_RESIZE_ALL_COLUMNS

public static final int AUTO_RESIZE_ALL_COLUMNS
Enabled: During all resize operations, proportionately resize all columns.


dataModel

protected javax.swing.table.TableModel dataModel
The TableModel of the table.


columnModel

protected javax.swing.table.TableColumnModel columnModel
The TableColumnModel of the table.


selectionModel

protected ListSelectionModel selectionModel
The ListSelectionModel of the table, used to keep track of row selections.


tableHeader

protected javax.swing.table.JTableHeader tableHeader
The TableHeader working with the table.


rowHeight

protected int rowHeight
The height in pixels of each row in the table.


rowMargin

protected int rowMargin
The height in pixels of the margin between the cells in each row.


gridColor

protected Color gridColor
The color of the grid.


showHorizontalLines

protected boolean showHorizontalLines
The table draws horizontal lines between cells if showHorizontalLines is true.


showVerticalLines

protected boolean showVerticalLines
The table draws vertical lines between cells if showVerticalLines is true.


autoResizeMode

protected int autoResizeMode
Determines if the table automatically resizes the width of the table's columns to take up the entire width of the table, and how it does the resizing.


autoCreateColumnsFromModel

protected boolean autoCreateColumnsFromModel
The table will query the TableModel to build the default set of columns if this is true.


preferredViewportSize

protected Dimension preferredViewportSize
Used by the Scrollable interface to determine the initial visible area.


rowSelectionAllowed

protected boolean rowSelectionAllowed
True if row selection is allowed in this table.


cellSelectionEnabled

protected boolean cellSelectionEnabled
Obsolete as of Java 2 platform v1.3. Please use the rowSelectionAllowed property and the columnSelectionAllowed property of the columnModel instead. Or use the method getCellSelectionEnabled.


editorComp

protected transient Component editorComp
If editing, the Component that is handling the editing.


cellEditor

protected transient javax.swing.table.TableCellEditor cellEditor
The object that overwrites the screen real estate occupied by the current cell and allows the user to change its contents.


editingColumn

protected transient int editingColumn
Identifies the column of the cell being edited.


editingRow

protected transient int editingRow
Identifies the row of the cell being edited.


defaultRenderersByColumnClass

protected transient Hashtable defaultRenderersByColumnClass
A table of objects that display the contents of a cell, indexed by class as declared in getColumnClass in the TableModel interface.


defaultEditorsByColumnClass

protected transient Hashtable defaultEditorsByColumnClass
A table of objects that display and edit the contents of a cell, indexed by class as declared in getColumnClass in the TableModel interface.


selectionForeground

protected Color selectionForeground
The foreground color of selected cells.


selectionBackground

protected Color selectionBackground
The background color of selected cells.


rowModel

private SizeSequence rowModel

dragEnabled

private boolean dragEnabled

surrendersFocusOnKeystroke

private boolean surrendersFocusOnKeystroke

editorRemover

private java.beans.PropertyChangeListener editorRemover
Constructor Detail

JTable

public JTable()
Enabled: Constructs a default JTable that is initialized with a default data model, a default column model, and a default selection model.

See Also:
createDefaultDataModel(), createDefaultColumnModel(), createDefaultSelectionModel()

JTable

public JTable(javax.swing.table.TableModel dm)
Enabled: Constructs a JTable that is initialized with dm as the data model, a default column model, and a default selection model.

Parameters:
dm - the data model for the table
See Also:
createDefaultColumnModel(), createDefaultSelectionModel()

JTable

public JTable(javax.swing.table.TableModel dm,
              javax.swing.table.TableColumnModel cm)
Enabled: Constructs a JTable that is initialized with dm as the data model, cm as the column model, and a default selection model.

Parameters:
dm - the data model for the table
cm - the column model for the table
See Also:
createDefaultSelectionModel()

JTable

public JTable(javax.swing.table.TableModel dm,
              javax.swing.table.TableColumnModel cm,
              ListSelectionModel sm)
Enabled: Constructs a JTable that is initialized with dm as the data model, cm as the column model, and sm as the selection model. If any of the parameters are null this method will initialize the table with the corresponding default model. The autoCreateColumnsFromModel flag is set to false if cm is non-null, otherwise it is set to true and the column model is populated with suitable TableColumns for the columns in dm.

Parameters:
dm - the data model for the table
cm - the column model for the table
sm - the row selection model for the table
See Also:
createDefaultDataModel(), createDefaultColumnModel(), createDefaultSelectionModel()

JTable

public JTable(int numRows,
              int numColumns)
Enabled: Constructs a JTable with numRows and numColumns of empty cells using DefaultTableModel. The columns will have names of the form "A", "B", "C", etc.

Parameters:
numRows - the number of rows the table holds
numColumns - the number of columns the table holds
See Also:
javax.swing.table.DefaultTableModel

JTable

public JTable(Vector rowData,
              Vector columnNames)
Enabled: Constructs a JTable to display the values in the Vector of Vectors, rowData, with column names, columnNames. The Vectors contained in rowData should contain the values for that row. In other words, the value of the cell at row 1, column 5 can be obtained with the following code:

((Vector)rowData.elementAt(1)).elementAt(5);

Parameters:
rowData - the data for the new table
columnNames - names of each column

JTable

public JTable(Object[][] rowData,
              Object[] columnNames)
Enabled: Constructs a JTable to display the values in the two dimensional array, rowData, with column names, columnNames. rowData is an array of rows, so the value of the cell at row 1, column 5 can be obtained with the following code:

 rowData[1][5]; 

All rows must be of the same length as columnNames.

Parameters:
rowData - the data for the new table
columnNames - names of each column
Method Detail

addNotify

public void addNotify()
Suppressed: Calls the configureEnclosingScrollPane method.

Overrides:
addNotify in class JComponent
See Also:
configureEnclosingScrollPane()

configureEnclosingScrollPane

protected void configureEnclosingScrollPane()
If this JTable is the viewportView of an enclosing JScrollPane (the usual situation), configure this ScrollPane by, amongst other things, installing the table's tableHeader as the columnHeaderView of the scroll pane. When a JTable is added to a JScrollPane in the usual way, using new JScrollPane(myTable), addNotify is called in the JTable (when the table is added to the viewport). JTable's addNotify method in turn calls this method, which is protected so that this default installation procedure can be overridden by a subclass.

See Also:
addNotify()

removeNotify

public void removeNotify()
Suppressed: Calls the unconfigureEnclosingScrollPane method.

Overrides:
removeNotify in class JComponent
See Also:
unconfigureEnclosingScrollPane()

unconfigureEnclosingScrollPane

protected void unconfigureEnclosingScrollPane()
Reverses the effect of configureEnclosingScrollPane by replacing the columnHeaderView of the enclosing scroll pane with null. JTable's removeNotify method calls this method, which is protected so that this default uninstallation procedure can be overridden by a subclass.

See Also:
removeNotify(), configureEnclosingScrollPane()

createScrollPaneForTable

public static JScrollPane createScrollPaneForTable(JTable aTable)
Deprecated. As of Swing version 1.0.2, replaced by new JScrollPane(aTable).

Suppressed: Equivalent to new JScrollPane(aTable).


setTableHeader

public void setTableHeader(javax.swing.table.JTableHeader tableHeader)
Enabled: Sets the tableHeader working with this JTable to newHeader. It is legal to have a null tableHeader.

See Also:
getTableHeader()

getTableHeader

public javax.swing.table.JTableHeader getTableHeader()
Enabled: Returns the tableHeader used by this JTable.

Returns:
the tableHeader used by this table
See Also:
setTableHeader(javax.swing.table.JTableHeader)

setRowHeight

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

Parameters:
rowHeight - new row height
See Also:
getRowHeight()

getRowHeight

public int getRowHeight()
Enabled: Returns the height of a table row, in pixels. The default row height is 16.0.

Returns:
the height in pixels of a table row
See Also:
setRowHeight(int)

getRowModel

private SizeSequence getRowModel()

setRowHeight

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

Parameters:
row - the row whose height is being changed
rowHeight - new row height, in pixels

getRowHeight

public int getRowHeight(int row)
Enabled: Returns the height, in pixels, of the cells in row.

Parameters:
row - the row whose height is to be returned
Returns:
the height, in pixels, of the cells in the row

setRowMargin

public void setRowMargin(int rowMargin)
Enabled: Sets the amount of empty space between cells in adjacent rows.

Parameters:
rowMargin - the number of pixels between cells in a row
See Also:
getRowMargin()

getRowMargin

public int getRowMargin()
Enabled: Gets the amount of empty space, in pixels, between cells. Equivalent to: getIntercellSpacing().height.

Returns:
the number of pixels between cells in a row
See Also:
setRowMargin(int)

setIntercellSpacing

public void setIntercellSpacing(Dimension intercellSpacing)
Enabled: Sets the rowMargin and the columnMargin -- the height and width of the space between cells -- to intercellSpacing.

Parameters:
intercellSpacing - a Dimension specifying the new width and height between cells
See Also:
getIntercellSpacing()

getIntercellSpacing

public Dimension getIntercellSpacing()
Enabled: Returns the horizontal and vertical space between cells. The default spacing is (1, 1), which provides room to draw the grid.

Returns:
the horizontal and vertical spacing between cells
See Also:
setIntercellSpacing(java.awt.Dimension)

setGridColor

public void setGridColor(Color gridColor)
Enabled: Sets the color used to draw grid lines to gridColor and redisplays. The default color is look and feel dependent.

Parameters:
gridColor - the new color of the grid lines
See Also:
getGridColor()

getGridColor

public Color getGridColor()
Enabled: Returns the color used to draw grid lines. The default color is look and feel dependent.

Returns:
the color used to draw grid lines
See Also:
setGridColor(java.awt.Color)

setShowGrid

public void setShowGrid(boolean showGrid)
Enabled: Sets whether the table draws grid lines around cells. If showGrid is true it does; if it is false it doesn't. There is no getShowGrid method as this state is held in two variables -- showHorizontalLines and showVerticalLines -- each of which can be queried independently.

Parameters:
showGrid - true if table view should draw grid lines
See Also:
setShowVerticalLines(boolean), setShowHorizontalLines(boolean)

setShowHorizontalLines

public void setShowHorizontalLines(boolean showHorizontalLines)
Enabled: Sets whether the table draws horizontal lines between cells. If showHorizontalLines is true it does; if it is false it doesn't.

Parameters:
showHorizontalLines - true if table view should draw horizontal lines
See Also:
getShowHorizontalLines(), setShowGrid(boolean), setShowVerticalLines(boolean)

setShowVerticalLines

public void setShowVerticalLines(boolean showVerticalLines)
Enabled: Sets whether the table draws vertical lines between cells. If showVerticalLines is true it does; if it is false it doesn't.

Parameters:
showVerticalLines - true if table view should draw vertical lines
See Also:
getShowVerticalLines(), setShowGrid(boolean), setShowHorizontalLines(boolean)

getShowHorizontalLines

public boolean getShowHorizontalLines()
Enabled: Returns true if the table draws horizontal lines between cells, false if it doesn't. The default is true.

Returns:
true if the table draws horizontal lines between cells, false if it doesn't
See Also:
setShowHorizontalLines(boolean)

getShowVerticalLines

public boolean getShowVerticalLines()
Enabled: Returns true if the table draws vertical lines between cells, false if it doesn't. The default is true.

Returns:
true if the table draws vertical lines between cells, false if it doesn't
See Also:
setShowVerticalLines(boolean)

setAutoResizeMode

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

Parameters:
mode - One of 5 legal values: AUTO_RESIZE_OFF, AUTO_RESIZE_NEXT_COLUMN, AUTO_RESIZE_SUBSEQUENT_COLUMNS, AUTO_RESIZE_LAST_COLUMN, AUTO_RESIZE_ALL_COLUMNS
See Also:
getAutoResizeMode(), doLayout()

getAutoResizeMode

public int getAutoResizeMode()
Enabled: Returns the auto resize mode of the table. The default mode is AUTO_RESIZE_SUBSEQUENT_COLUMNS.

Returns:
the autoResizeMode of the table
See Also:
setAutoResizeMode(int), doLayout()

setAutoCreateColumnsFromModel

public void setAutoCreateColumnsFromModel(boolean autoCreateColumnsFromModel)
Enabled: Sets this table's autoCreateColumnsFromModel flag. This method calls createDefaultColumnsFromModel if autoCreateColumnsFromModel changes from false to true.

Parameters:
autoCreateColumnsFromModel - true if JTable should automatically create columns
See Also:
getAutoCreateColumnsFromModel(), createDefaultColumnsFromModel()

getAutoCreateColumnsFromModel

public boolean getAutoCreateColumnsFromModel()
Enabled: Determines whether the table will create default columns from the model. If true, setModel will clear any existing columns and create new columns from the new model. Also, if the event in the tableChanged notification specifies that the entire table changed, then the columns will be rebuilt. The default is true.

Returns:
the autoCreateColumnsFromModel of the table
See Also:
setAutoCreateColumnsFromModel(boolean), createDefaultColumnsFromModel()

createDefaultColumnsFromModel

public void createDefaultColumnsFromModel()
Enabled: Creates default columns for the table from the data model using the getColumnCount method defined in the TableModel interface.

Clears any existing columns before creating the new columns based on information from the model.

See Also:
getAutoCreateColumnsFromModel()

setDefaultRenderer

public void setDefaultRenderer(Class columnClass,
                               javax.swing.table.TableCellRenderer renderer)
Enabled: Sets a default cell renderer to be used if no renderer has been set in a TableColumn. If renderer is null, removes the default renderer for this column class.

Parameters:
columnClass - set the default cell renderer for this columnClass
renderer - default cell renderer to be used for this columnClass
See Also:
getDefaultRenderer(java.lang.Class), setDefaultEditor(java.lang.Class, javax.swing.table.TableCellEditor)

getDefaultRenderer

public javax.swing.table.TableCellRenderer getDefaultRenderer(Class columnClass)
Enabled: Returns the cell renderer to be used when no renderer has been set in a TableColumn. During the rendering of cells the renderer is fetched from a Hashtable of entries according to the class of the cells in the column. If there is no entry for this columnClass the method returns the entry for the most specific superclass. The JTable installs entries for Object, Number, and Boolean, all of which can be modified or replaced.

Parameters:
columnClass - return the default cell renderer for this columnClass
Returns:
the renderer for this columnClass
See Also:
setDefaultRenderer(java.lang.Class, javax.swing.table.TableCellRenderer), getColumnClass(int)

setDefaultEditor

public void setDefaultEditor(Class columnClass,
                             javax.swing.table.TableCellEditor editor)
Enabled: Sets a default cell editor to be used if no editor has been set in a TableColumn. If no editing is required in a table, or a particular column in a table, uses the isCellEditable method in the TableModel interface to ensure that this JTable will not start an editor in these columns. If editor is null, removes the default editor for this column class.

Parameters:
columnClass - set the default cell editor for this columnClass
editor - default cell editor to be used for this columnClass
See Also:
TableModel#isCellEditable, getDefaultEditor(java.lang.Class), setDefaultRenderer(java.lang.Class, javax.swing.table.TableCellRenderer)

getDefaultEditor

public javax.swing.table.TableCellEditor getDefaultEditor(Class columnClass)
Enabled: Returns the editor to be used when no editor has been set in a TableColumn. During the editing of cells the editor is fetched from a Hashtable of entries according to the class of the cells in the column. If there is no entry for this columnClass the method returns the entry for the most specific superclass. The JTable installs entries for Object, Number, and Boolean, all of which can be modified or replaced.

Parameters:
columnClass - return the default cell editor for this columnClass
Returns:
the default cell editor to be used for this columnClass
See Also:
setDefaultEditor(java.lang.Class, javax.swing.table.TableCellEditor), getColumnClass(int)

setDragEnabled

public void setDragEnabled(boolean b)
Enabled: Sets the dragEnabled property, which must be true to enable automatic drag handling (the first part of drag and drop) on this component. The transferHandler property needs to be set to a non-null value for the drag to do anything. The default value of the dragEnabledfalse.

When automatic drag handling is enabled, most look and feels begin a drag-and-drop operation whenever the user presses the mouse button over a selection and then moves the mouse a few pixels. Setting this property to true can therefore have a subtle effect on how selections behave.

Some look and feels might not support automatic drag and drop; they will ignore this property. You can work around such look and feels by modifying the component to directly call the exportAsDrag method of a TransferHandler.

Parameters:
b - the value to set the dragEnabled property to
Since:
1.4
See Also:
java.awt.GraphicsEnvironment#isHeadless, getDragEnabled(), JComponent.setTransferHandler(javax.swing.TransferHandler), TransferHandler

getDragEnabled

public boolean getDragEnabled()
Enabled: Gets the value of the dragEnabled property.

Returns:
the value of the dragEnabled property
Since:
1.4
See Also:
setDragEnabled(boolean)

setSelectionMode

public void setSelectionMode(int selectionMode)
Enabled: Sets the table's selection mode to allow only single selections, a single contiguous interval, or multiple intervals.

Note: JTable provides all the methods for handling column and row selection. When setting states, such as setSelectionMode, it not only updates the mode for the row selection model but also sets similar values in the selection model of the columnModel. If you want to have the row and column selection models operating in different modes, set them both directly.

Both the row and column selection models for JTable default to using a DefaultListSelectionModel so that JTable works the same way as the JList. See the setSelectionMode method in JList for details about the modes.

See Also:
JList.setSelectionMode(int)

setRowSelectionAllowed

public void setRowSelectionAllowed(boolean rowSelectionAllowed)
Enabled: Sets whether the rows in this model can be selected.

Parameters:
rowSelectionAllowed - true if this model will allow row selection
See Also:
getRowSelectionAllowed()

getRowSelectionAllowed

public boolean getRowSelectionAllowed()
Enabled: Returns true if rows can be selected.

Returns:
true if rows can be selected, otherwise false
See Also:
setRowSelectionAllowed(boolean)

setColumnSelectionAllowed

public void setColumnSelectionAllowed(boolean columnSelectionAllowed)
Enabled: Sets whether the columns in this model can be selected.

Parameters:
columnSelectionAllowed - true if this model will allow column selection
See Also:
getColumnSelectionAllowed()

getColumnSelectionAllowed

public boolean getColumnSelectionAllowed()
Enabled: Returns true if columns can be selected.

Returns:
true if columns can be selected, otherwise false
See Also:
setColumnSelectionAllowed(boolean)

setCellSelectionEnabled

public void setCellSelectionEnabled(boolean cellSelectionEnabled)
Enabled: Sets whether this table allows both a column selection and a row selection to exist simultaneously. When set, the table treats the intersection of the row and column selection models as the selected cells. Override isCellSelected to change this default behavior. This method is equivalent to setting both the rowSelectionAllowed property and columnSelectionAllowed property of the columnModel to the supplied value.

Parameters:
cellSelectionEnabled - true if simultaneous row and column selection is allowed
See Also:
getCellSelectionEnabled(), isCellSelected(int, int)

getCellSelectionEnabled

public boolean getCellSelectionEnabled()
Enabled: Returns true if both row and column selection models are enabled. Equivalent to getRowSelectionAllowed() && getColumnSelectionAllowed().

Returns:
true if both row and column selection models are enabled
See Also:
setCellSelectionEnabled(boolean)

selectAll

public void selectAll()
Enabled: Selects all rows, columns, and cells in the table.


clearSelection

public void clearSelection()
Enabled: Deselects all selected columns and rows.


boundRow

private int boundRow(int row)
              throws IllegalArgumentException
IllegalArgumentException

boundColumn

private int boundColumn(int col)

setRowSelectionInterval

public void setRowSelectionInterval(int index0,
                                    int index1)
Enabled: Selects the rows from index0 to index1, inclusive.

Parameters:
index0 - one end of the interval
index1 - the other end of the interval

setColumnSelectionInterval

public void setColumnSelectionInterval(int index0,
                                       int index1)
Enabled: Selects the columns from index0 to index1, inclusive.

Parameters:
index0 - one end of the interval
index1 - the other end of the interval

addRowSelectionInterval

public void addRowSelectionInterval(int index0,
                                    int index1)
Enabled: Adds the rows from index0 to index1, inclusive, to the current selection.

Parameters:
index0 - one end of the interval
index1 - the other end of the interval

addColumnSelectionInterval

public void addColumnSelectionInterval(int index0,
                                       int index1)
Enabled: Adds the columns from index0 to index1, inclusive, to the current selection.

Parameters:
index0 - one end of the interval
index1 - the other end of the interval

removeRowSelectionInterval

public void removeRowSelectionInterval(int index0,
                                       int index1)
Enabled: Deselects the rows from index0 to index1, inclusive.

Parameters:
index0 - one end of the interval
index1 - the other end of the interval

removeColumnSelectionInterval

public void removeColumnSelectionInterval(int index0,
                                          int index1)
Enabled: Deselects the columns from index0 to index1, inclusive.

Parameters:
index0 - one end of the interval
index1 - the other end of the interval

getSelectedRow

public int getSelectedRow()
Enabled: Returns the index of the first selected row, -1 if no row is selected.

Returns:
the index of the first selected row

getSelectedColumn

public int getSelectedColumn()
Enabled: Returns the index of the first selected column, -1 if no column is selected.

Returns:
the index of the first selected column

getSelectedRows

public int[] getSelectedRows()
Enabled: Returns the indices of all selected rows.

Returns:
an array of integers containing the indices of all selected rows, or an empty array if no row is selected
See Also:
getSelectedRow()

getSelectedColumns

public int[] getSelectedColumns()
Enabled: Returns the indices of all selected columns.

Returns:
an array of integers containing the indices of all selected columns, or an empty array if no column is selected
See Also:
getSelectedColumn()

getSelectedRowCount

public int getSelectedRowCount()
Enabled: Returns the number of selected rows.

Returns:
the number of selected rows, 0 if no rows are selected

getSelectedColumnCount

public int getSelectedColumnCount()
Enabled: Returns the number of selected columns.

Returns:
the number of selected columns, 0 if no columns are selected

isRowSelected

public boolean isRowSelected(int row)
Enabled: Returns true if the row at the specified index is selected.

Returns:
true if the row at index row is selected, where 0 is the first row

isColumnSelected

public boolean isColumnSelected(int column)
Enabled: Returns true if the column at the specified index is selected.

Parameters:
column - the column in the column model
Returns:
true if the column at index column is selected, where 0 is the first column

isCellSelected

public boolean isCellSelected(int row,
                              int column)
Enabled: Returns true if the cell at the specified position is selected.

Parameters:
row - the row being queried
column - the column being queried
Returns:
true if the cell at index (row, column) is selected, where the first row and first column are at index 0

changeSelectionModel

private void changeSelectionModel(ListSelectionModel sm,
                                  int index,
                                  boolean toggle,
                                  boolean extend,
                                  boolean selected)

changeSelection

public void changeSelection(int rowIndex,
                            int columnIndex,
                            boolean toggle,
                            boolean extend)
Enabled: Updates the selection models of the table, depending on the state of the two flags: toggle and extend. All 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.

This implementation uses the following conventions:

Parameters:
rowIndex - affects the selection at row
columnIndex - affects the selection at column
toggle - see description above
extend - if true, extend the current selection

getSelectionForeground

public Color getSelectionForeground()
Enabled: Returns the foreground color for selected cells.

Returns:
the Color object for the foreground property
See Also:
setSelectionForeground(java.awt.Color), setSelectionBackground(java.awt.Color)

setSelectionForeground

public void setSelectionForeground(Color selectionForeground)
Enabled: Sets the foreground color for selected cells. Cell renderers can use this color to render text and graphics for selected cells.

The default value of this property is defined by the look and feel implementation.

This is a JavaBeans bound property.

Parameters:
selectionForeground - the Color to use in the foreground for selected list items
See Also:
getSelectionForeground(), setSelectionBackground(java.awt.Color), JComponent.setForeground(java.awt.Color), JComponent.setBackground(java.awt.Color), JComponent.setFont(java.awt.Font)

getSelectionBackground

public Color getSelectionBackground()
Enabled: Returns the background color for selected cells.

Returns:
the Color used for the background of selected list items
See Also:
setSelectionBackground(java.awt.Color), setSelectionForeground(java.awt.Color)

setSelectionBackground

public void setSelectionBackground(Color selectionBackground)
Enabled: Sets the background color for selected cells. Cell renderers can use this color to the fill selected cells.

The default value of this property is defined by the look and feel implementation.

This is a JavaBeans bound property.

Parameters:
selectionBackground - the Color to use for the background of selected cells
See Also:
getSelectionBackground(), setSelectionForeground(java.awt.Color), JComponent.setForeground(java.awt.Color), JComponent.setBackground(java.awt.Color), JComponent.setFont(java.awt.Font)

getColumn

public javax.swing.table.TableColumn getColumn(Object identifier)
Enabled: Returns the TableColumn object for the column in the table whose identifier is equal to identifier, when compared using equals.

Parameters:
identifier - the identifier object
Returns:
the TableColumn object that matches the identifier

convertColumnIndexToModel

public int convertColumnIndexToModel(int viewColumnIndex)
Enabled: Maps the index of the column in the view at viewColumnIndex to the index of the column in the table model. Returns the index of the corresponding column in the model. If viewColumnIndex is less than zero, returns viewColumnIndex.

Parameters:
viewColumnIndex - the index of the column in the view
Returns:
the index of the corresponding column in the model
See Also:
convertColumnIndexToView(int)

convertColumnIndexToView

public int convertColumnIndexToView(int modelColumnIndex)
Enabled: Maps the index of the column in the table model at modelColumnIndex to the index of the column in the view. Returns the index of the corresponding column in the view; returns -1 if this column is not being displayed. If modelColumnIndex is less than zero, returns modelColumnIndex.

Parameters:
modelColumnIndex - the index of the column in the model
Returns:
the index of the corresponding column in the view
See Also:
convertColumnIndexToModel(int)

getRowCount

public int getRowCount()
Enabled: Returns the number of rows in this table's model.

Returns:
the number of rows in this table's model
See Also:
getColumnCount()

getColumnCount

public int getColumnCount()
Enabled: Returns the number of columns in the column model. Note that this may be different from the number of columns in the table model.

Returns:
the number of columns in the table
See Also:
getRowCount(), removeColumn(javax.swing.table.TableColumn)

getColumnName

public String getColumnName(int column)
Enabled: Returns the name of the column appearing in the view at column position column.

Parameters:
column - the column in the view being queried
Returns:
the name of the column at position column in the view where the first column is column 0

getColumnClass

public Class getColumnClass(int column)
Enabled: Returns the type of the column appearing in the view at column position column.

Parameters:
column - the column in the view being queried
Returns:
the type of the column at position column in the view where the first column is column 0

getValueAt

public Object getValueAt(int row,
                         int column)
Enabled: Returns the cell value at row and column.

Note: The column is specified in the table view's display order, and not in the TableModel's column order. This is an important distinction because as the user rearranges the columns in the table, the column at a given index in the view will change. Meanwhile the user's actions never affect the model's column ordering.

Parameters:
row - the row whose value is to be queried
column - the column whose value is to be queried
Returns:
the Object at the specified cell

setValueAt

public void setValueAt(Object aValue,
                       int row,
                       int column)
Enabled: Sets the value for the cell in the table model at row and column.

Note: The column is specified in the table view's display order, and not in the TableModel's column order. This is an important distinction because as the user rearranges the columns in the table, the column at a given index in the view will change. Meanwhile the user's actions never affect the model's column ordering. aValue is the new value.

Parameters:
aValue - the new value
row - the row of the cell to be changed
column - the column of the cell to be changed
See Also:
getValueAt(int, int)

isCellEditable

public boolean isCellEditable(int row,
                              int column)
Enabled: Returns true if the cell at row and column is editable. Otherwise, invoking setValueAt on the cell will have no effect.

Note: The column is specified in the table view's display order, and not in the TableModel's column order. This is an important distinction because as the user rearranges the columns in the table, the column at a given index in the view will change. Meanwhile the user's actions never affect the model's column ordering.

Parameters:
row - the row whose value is to be queried
column - the column whose value is to be queried
Returns:
true if the cell is editable
See Also:
setValueAt(java.lang.Object, int, int)

addColumn

public void addColumn(javax.swing.table.TableColumn aColumn)
Enabled: Appends aColumn to the end of the array of columns held by this JTable's column model. If the column name of aColumn is null, sets the column name of aColumn to the name returned by getModel().getColumnName().

To add a column to this JTable to display the modelColumn'th column of data in the model with a given width, cellRenderer, and cellEditor you can use:


      addColumn(new TableColumn(modelColumn, width, cellRenderer, cellEditor));

  
[Any of the TableColumn constructors can be used instead of this one.] The model column number is stored inside the TableColumn and is used during rendering and editing to locate the appropriates data values in the model. The model column number does not change when columns are reordered in the view.

Parameters:
aColumn - the TableColumn to be added
See Also:
removeColumn(javax.swing.table.TableColumn)

removeColumn

public void removeColumn(javax.swing.table.TableColumn aColumn)
Enabled: Removes aColumn from this JTable's array of columns. Note: this method does not remove the column of data from the model; it just removes the TableColumn that was responsible for displaying it.

Parameters:
aColumn - the TableColumn to be removed
See Also:
addColumn(javax.swing.table.TableColumn)

moveColumn

public void moveColumn(int column,
                       int targetColumn)
Enabled: Moves the column column to the position currently occupied by the column targetColumn in the view. The old column at targetColumn is shifted left or right to make room.

Parameters:
column - the index of column to be moved
targetColumn - the new index of the column

columnAtPoint

public int columnAtPoint(Point point)
Enabled: Returns the index of the column that point lies in, or -1 if the result is not in the range [0, getColumnCount()-1].

Parameters:
point - the location of interest
Returns:
the index of the column that point lies in, or -1 if the result is not in the range [0, getColumnCount()-1]
See Also:
rowAtPoint(java.awt.Point)

rowAtPoint

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

Parameters:
point - the location of interest
Returns:
the index of the row that point lies in, or -1 if the result is not in the range [0, getRowCount()-1]
See Also:
columnAtPoint(java.awt.Point)

getCellRect

public Rectangle getCellRect(int row,
                             int column,
                             boolean includeSpacing)
Enabled: Returns a rectangle for the cell that lies at the intersection of row and column. If includeSpacing is true then the value returned has the full height and width of the row and column specified. If it is false, the returned rectangle is inset by the intercell spacing to return the true bounds of the rendering or editing component as it will be set during rendering.

If the column index is valid but the row index is less than zero the method returns a rectangle with the y and height values set appropriately and the x and width values both set to zero. In general, when either the row or column indices indicate a cell outside the appropriate range, the method returns a rectangle depicting the closest edge of the closest cell that is within the table's range. When both row and column indices are out of range the returned rectangle covers the closest point of the closest cell.

In all cases, calculations that use this method to calculate results along one axis will not fail because of anomalies in calculations along the other axis. When the cell is not valid the includeSpacing parameter is ignored.

Parameters:
row - the row index where the desired cell is located
column - the column index where the desired cell is located in the display; this is not necessarily the same as the column index in the data model for the table; the convertColumnIndexToView(int) method may be used to convert a data model column index to a display column index
includeSpacing - if false, return the true cell bounds - computed by subtracting the intercell spacing from the height and widths of the column and row models
Returns:
the rectangle containing the cell at location row,column

viewIndexForColumn

private int viewIndexForColumn(javax.swing.table.TableColumn aColumn)

doLayout

public void doLayout()
Enabled: Causes this table to lay out its rows and columns. Overridden so that columns can be resized to accomodate a change in the size of a containing parent. Resizes one or more of the columns in the table so that the total width of all of this JTable's columns is equal to the width of the table.

Before the layout begins the method gets the resizingColumn of the tableHeader. When the method is called as a result of the resizing of an enclosing window, the resizingColumn is null. This means that resizing has taken place "outside" the JTable and the change - or "delta" - should be distributed to all of the columns regardless of this JTable's automatic resize mode.

If the resizingColumn is not null, it is one of the columns in the table that has changed size rather than the table itself. In this case the auto-resize modes govern the way the extra (or deficit) space is distributed amongst the available columns.

The modes are:

Note: When a JTable makes adjustments to the widths of the columns it respects their minimum and maximum values absolutely. It is therefore possible that, even after this method is called, the total width of the columns is still not equal to the width of the table. When this happens the JTable does not put itself in AUTO_RESIZE_OFF mode to bring up a scroll bar, or break other commitments of its current auto-resize mode -- instead it allows its bounds to be set larger (or smaller) than the total of the column minimum or maximum, meaning, either that there will not be enough room to display all of the columns, or that the columns will not fill the JTable's bounds. These respectively, result in the clipping of some columns or an area being painted in the JTable's background color during painting.

The mechanism for distributing the delta amongst the available columns is provided in a private method in the JTable class:

   adjustSizes(long targetSize, final Resizable3 r, boolean inverse)
 
an explanation of which is provided in the following section. Resizable3 is a private interface that allows any data structure containing a collection of elements with a size, preferred size, maximum size and minimum size to have its elements manipulated by the algorithm.

Distributing the delta

Overview

Call "DELTA" the difference between the target size and the sum of the preferred sizes of the elements in r. The individual sizes are calculated by taking the original preferred sizes and adding a share of the DELTA - that share being based on how far each preferred size is from its limiting bound (minimum or maximum).

Definition

Call the individual constraints min[i], max[i], and pref[i].

Call their respective sums: MIN, MAX, and PREF.

Each new size will be calculated using:

          size[i] = pref[i] + delta[i]
 
where each individual delta[i] is calculated according to:

If (DELTA < 0) we are in shrink mode where:

                        DELTA
          delta[i] = ------------ * (pref[i] - min[i])
                     (PREF - MIN)
 
If (DELTA > 0) we are in expand mode where:

                        DELTA
          delta[i] = ------------ * (max[i] - pref[i])
                      (MAX - PREF)
 

The overall effect is that the total size moves that same percentage, k, towards the total minimum or maximum and that percentage guarantees accomodation of the required space, DELTA.

Details

Naive evaluation of the formulae presented here would be subject to the aggregated rounding errors caused by doing this operation in finite precision (using ints). To deal with this, the multiplying factor above, is constantly recalculated and this takes account of the rounding errors in the previous iterations. The result is an algorithm that produces a set of integers whose values exactly sum to the supplied targetSize, and does so by spreading the rounding errors evenly over the given elements.

When the MAX and MIN bounds are hit

When targetSize is outside the [MIN, MAX] range, the algorithm sets all sizes to their appropriate limiting value (maximum or minimum).

Overrides:
doLayout in class Container
See Also:
LayoutManager.layoutContainer(java.awt.Container), Container.setLayout(java.awt.LayoutManager), Container.validate()

getResizingColumn

private javax.swing.table.TableColumn getResizingColumn()

sizeColumnsToFit

public void sizeColumnsToFit(boolean lastColumnOnly)
Deprecated. As of Swing version 1.0.3, replaced by doLayout().

Enabled: Sizes the table columns to fit the available space.

See Also:
doLayout()

sizeColumnsToFit

public void sizeColumnsToFit(int resizingColumn)
Enabled: Obsolete as of Java 2 platform v1.4. Please use the doLayout() method instead.

Parameters:
resizingColumn - the column whose resizing made this adjustment necessary or -1 if there is no such column
See Also:
doLayout()

setWidthsFromPreferredWidths

private void setWidthsFromPreferredWidths(boolean inverse)

accommodateDelta

private void accommodateDelta(int resizingColumnIndex,
                              int delta)

adjustSizes

private void adjustSizes(long target,
                         javax.swing.JTable.Resizable3 r,
                         boolean inverse)

adjustSizes

private void adjustSizes(long target,
                         javax.swing.JTable.Resizable2 r,
                         boolean limitToRange)

getToolTipText

public String getToolTipText(MouseEvent event)
Enabled: Overrides JComponent's getToolTipText method in order to allow the renderer's tips to be used if it has text set.

Note: For JTable to properly display tooltips of its renderers JTable must be a registered component with the ToolTipManager. This is done automatically in initializeLocalVars, but if at a later point JTable is told setToolTipText(null) it will unregister the table component, and no tips from renderers will display anymore.

Overrides:
getToolTipText in class JComponent
See Also:
JComponent.getToolTipText()

setSurrendersFocusOnKeystroke

public void setSurrendersFocusOnKeystroke(boolean surrendersFocusOnKeystroke)
Suppressed: Sets whether editors in this JTable get the keyboard focus when an editor is activated as a result of the JTable forwarding keyboard events for a cell. By default, this property is false, and the JTable retains the focus unless the cell is clicked.

Parameters:
surrendersFocusOnKeystroke - true if the editor should get the focus when keystrokes cause the editor to be activated
See Also:
getSurrendersFocusOnKeystroke()

getSurrendersFocusOnKeystroke

public boolean getSurrendersFocusOnKeystroke()
Enabled: Returns true if the editor should get the focus when keystrokes cause the editor to be activated

Returns:
true if the editor should get the focus when keystrokes cause the editor to be activated
See Also:
setSurrendersFocusOnKeystroke(boolean)

editCellAt

public boolean editCellAt(int row,
                          int column)
Enabled: Programmatically starts editing the cell at row and column, if the cell is editable. Note that this is a convenience method for editCellAt(int, int, null).

Parameters:
row - the row to be edited
column - the column to be edited
Returns:
false if for any reason the cell cannot be edited

editCellAt

public boolean editCellAt(int row,
                          int column,
                          EventObject e)
Enabled: Programmatically starts editing the cell at row and column, if the cell is editable. To prevent the JTable from editing a particular table, column or cell value, return false from the isCellEditable method in the TableModel interface.

Parameters:
row - the row to be edited
column - the column to be edited
e - event to pass into shouldSelectCell; note that as of Java 2 platform v1.2, the call to shouldSelectCell is no longer made
Returns:
false if for any reason the cell cannot be edited

isEditing

public boolean isEditing()
Enabled: Returns true if a cell is being edited.

Returns:
true if the table is editing a cell
See Also:
editingColumn, editingRow

getEditorComponent

public Component getEditorComponent()
Enabled: Returns the component that is handling the editing session. If nothing is being edited, returns null.

Returns:
Component handling editing session

getEditingColumn

public int getEditingColumn()
Enabled: Returns the index of the column that contains the cell currently being edited. If nothing is being edited, returns -1.

Returns:
the index of the column that contains the cell currently being edited; returns -1 if nothing being edited
See Also:
editingRow

getEditingRow

public int getEditingRow()
Enabled: Returns the index of the row that contains the cell currently being edited. If nothing is being edited, returns -1.

Returns:
the index of the row that contains the cell currently being edited; returns -1 if nothing being edited
See Also:
editingColumn

getUI

public javax.swing.plaf.TableUI getUI()
Suppressed: Returns the L&F object that renders this component.

Returns:
the TableUI object that renders this component

setUI

public void setUI(javax.swing.plaf.TableUI ui)
Suppressed: Sets the L&F object that renders this component and repaints.

Parameters:
ui - the TableUI L&F object
See Also:
UIDefaults.getUI(javax.swing.JComponent)

updateSubComponentUI

private void updateSubComponentUI(Object componentShell)

updateUI

public void updateUI()
Suppressed: Notification from the UIManager that the L&F has changed. Replaces the current UI object with the latest version from the UIManager.

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

getUIClassID

public String getUIClassID()
Suppressed: Returns the suffix used to construct the name of the L&F class used to render this component.

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

setModel

public void setModel(javax.swing.table.TableModel dataModel)
Enabled: Sets the data model for this table to newModel and registers with it for listener notifications from the new data model.

See Also:
getModel()

getModel

public javax.swing.table.TableModel getModel()
Enabled: Returns the TableModel that provides the data displayed by this JTable.

Returns:
the TableModel that provides the data displayed by this JTable
See Also:
setModel(javax.swing.table.TableModel)

setColumnModel

public void setColumnModel(javax.swing.table.TableColumnModel columnModel)
Enabled: Sets the column model for this table to newModel and registers for listener notifications from the new column model. Also sets the column model of the JTableHeader to columnModel.

Parameters:
columnModel - the new data source for this table
See Also:
getColumnModel()

getColumnModel

public javax.swing.table.TableColumnModel getColumnModel()
Enabled: Returns the TableColumnModel that contains all column information of this table.

Returns:
the object that provides the column state of the table
See Also:
setColumnModel(javax.swing.table.TableColumnModel)

setSelectionModel

public void setSelectionModel(ListSelectionModel newModel)
Enabled: Sets the row selection model for this table to newModel and registers for listener notifications from the new selection model.

Parameters:
newModel - the new selection model
See Also:
getSelectionModel()

getSelectionModel

public ListSelectionModel getSelectionModel()
Enabled: Returns the ListSelectionModel that is used to maintain row selection state.

Returns:
the object that provides row selection state, null if row selection is not allowed
See Also:
setSelectionModel(javax.swing.ListSelectionModel)

tableChanged

public void tableChanged(TableModelEvent e)
Suppressed: 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.

Note that as of 1.3, this method clears the selection, if any.

Specified by:
tableChanged in interface TableModelListener

tableRowsInserted

private void tableRowsInserted(TableModelEvent e)

tableRowsDeleted

private void tableRowsDeleted(TableModelEvent e)

columnAdded

public void columnAdded(TableColumnModelEvent e)
Suppressed: Invoked when a column is added to the table column model.

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

Specified by:
columnAdded in interface TableColumnModelListener
See Also:
TableColumnModelListener

columnRemoved

public void columnRemoved(TableColumnModelEvent e)
Suppressed: Invoked when a column is removed from the table column model.

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

Specified by:
columnRemoved in interface TableColumnModelListener
See Also:
TableColumnModelListener

columnMoved

public void columnMoved(TableColumnModelEvent e)
Suppressed: Invoked when a column is repositioned. If a cell is being edited, then editing is stopped and the cell is redrawn.

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

Specified by:
columnMoved in interface TableColumnModelListener
Parameters:
e - the event received
See Also:
TableColumnModelListener

columnMarginChanged

public void columnMarginChanged(ChangeEvent e)
Suppressed: Invoked when a column is moved due to a margin change. If a cell is being edited, then editing is stopped and the cell is redrawn.

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

Specified by:
columnMarginChanged in interface TableColumnModelListener
Parameters:
e - the event received
See Also:
TableColumnModelListener

limit

private int limit(int i,
                  int a,
                  int b)

columnSelectionChanged

public void columnSelectionChanged(ListSelectionEvent e)
Suppressed: Invoked when the selection model of the TableColumnModel is changed.

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

Specified by:
columnSelectionChanged in interface TableColumnModelListener
Parameters:
e - the event received
See Also:
TableColumnModelListener

valueChanged

public void valueChanged(ListSelectionEvent e)
Suppressed: Invoked when the row selection changes -- repaints to show the new selection.

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

Specified by:
valueChanged in interface ListSelectionListener
Parameters:
e - the event received
See Also:
ListSelectionListener

editingStopped

public void editingStopped(ChangeEvent e)
Suppressed: Invoked when editing is finished. The changes are saved and the editor is discarded.

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

Specified by:
editingStopped in interface CellEditorListener
Parameters:
e - the event received
See Also:
CellEditorListener

editingCanceled

public void editingCanceled(ChangeEvent e)
Suppressed: Invoked when editing is canceled. The editor object is discarded and the cell is rendered once again.

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

Specified by:
editingCanceled in interface CellEditorListener
Parameters:
e - the event received
See Also:
CellEditorListener

setPreferredScrollableViewportSize

public void setPreferredScrollableViewportSize(Dimension size)
Enabled: Sets the preferred size of the viewport for this table.

Parameters:
size - a Dimension object specifying the preferredSize of a JViewport whose view is this table
See Also:
Scrollable.getPreferredScrollableViewportSize()

getPreferredScrollableViewportSize

public Dimension getPreferredScrollableViewportSize()
Enabled: Returns the preferred size of the viewport for this table.

Specified by:
getPreferredScrollableViewportSize in interface Scrollable
Returns:
a Dimension object containing the preferredSize of the JViewport which displays this table
See Also:
Scrollable.getPreferredScrollableViewportSize()

getScrollableUnitIncrement

public int getScrollableUnitIncrement(Rectangle visibleRect,
                                      int orientation,
                                      int direction)
Enabled: Returns the scroll increment (in pixels) that completely exposes one new row or column (depending on the orientation).

This method is called each time the user requests a unit scroll.

Specified by:
getScrollableUnitIncrement in interface Scrollable
Parameters:
visibleRect - the view area visible within the viewport
orientation - either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL
direction - less than zero to scroll up/left, greater than zero for down/right
Returns:
the "unit" increment for scrolling in the specified direction
See Also:
Scrollable.getScrollableUnitIncrement(java.awt.Rectangle, int, int)

getScrollableBlockIncrement

public int getScrollableBlockIncrement(Rectangle visibleRect,
                                       int orientation,
                                       int direction)
Enabled: Returns visibleRect.height or visibleRect.width, depending on this table's orientation. Note that as of Swing 1.1.1 (Java 2 v 1.2.2) the value returned will ensure that the viewport is cleanly aligned on a row boundary.

Specified by:
getScrollableBlockIncrement in interface Scrollable
Parameters:
visibleRect - The view area visible within the viewport
orientation - Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.
direction - Less than zero to scroll up/left, greater than zero for down/right.
Returns:
visibleRect.height or visibleRect.width per the orientation
See Also:
Scrollable.getScrollableBlockIncrement(java.awt.Rectangle, int, int)

getScrollableTracksViewportWidth

public boolean getScrollableTracksViewportWidth()
Enabled: Returns false if autoResizeMode is set to AUTO_RESIZE_OFF, which indicates that the width of the viewport does not determine the width of the table. Otherwise returns true.

Specified by:
getScrollableTracksViewportWidth in interface Scrollable
Returns:
false if autoResizeMode is set to AUTO_RESIZE_OFF, otherwise returns true
See Also:
Scrollable.getScrollableTracksViewportWidth()

getScrollableTracksViewportHeight

public boolean getScrollableTracksViewportHeight()
Enabled: Returns false to indicate that the height of the viewport does not determine the height of the table.

Specified by:
getScrollableTracksViewportHeight in interface Scrollable
Returns:
false
See Also:
Scrollable.getScrollableTracksViewportHeight()

processKeyBinding

protected boolean processKeyBinding(KeyStroke ks,
                                    KeyEvent e,
                                    int condition,
                                    boolean pressed)
Description copied from class: JComponent
Invoked to process the key bindings for ks as the result of the KeyEvent e. This obtains the appropriate InputMap, gets the binding, gets the action from the ActionMap, and then (if the action is found and the component is enabled) invokes notifyAction to notify the action.

Overrides:
processKeyBinding in class JComponent
Parameters:
ks - the KeyStroke queried
e - the KeyEvent
condition - one of the following values:
  • JComponent.WHEN_FOCUSED
  • JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
  • JComponent.WHEN_IN_FOCUSED_WINDOW
pressed - true if the key is pressed
Returns:
true if there was a binding to an action, and the action was enabled

setLazyValue

private void setLazyValue(Hashtable h,
                          Class c,
                          String s)

setLazyRenderer

private void setLazyRenderer(Class c,
                             String s)

createDefaultRenderers

protected void createDefaultRenderers()
Creates default cell renderers for objects, numbers, doubles, dates, booleans, and icons.

See Also:
javax.swing.table.DefaultTableCellRenderer

setLazyEditor

private void setLazyEditor(Class c,
                           String s)

createDefaultEditors

protected void createDefaultEditors()
Creates default cell editors for objects, numbers, and boolean values.

See Also:
DefaultCellEditor

initializeLocalVars

protected void initializeLocalVars()
Initializes table properties to their default values.


createDefaultDataModel

protected javax.swing.table.TableModel createDefaultDataModel()
Returns the default table model object, which is a DefaultTableModel. A subclass can override this method to return a different table model object.

Returns:
the default table model object
See Also:
javax.swing.table.DefaultTableModel

createDefaultColumnModel

protected javax.swing.table.TableColumnModel createDefaultColumnModel()
Returns the default column model object, which is a DefaultTableColumnModel. A subclass can override this method to return a different column model object.

Returns:
the default column model object
See Also:
javax.swing.table.DefaultTableColumnModel

createDefaultSelectionModel

protected ListSelectionModel createDefaultSelectionModel()
Returns the default selection model object, which is a DefaultListSelectionModel. A subclass can override this method to return a different selection model object.

Returns:
the default selection model object
See Also:
javax.swing.DefaultListSelectionModel

createDefaultTableHeader

protected javax.swing.table.JTableHeader createDefaultTableHeader()
Returns the default table header object, which is a JTableHeader. A subclass can override this method to return a different table header object.

Returns:
the default table header object
See Also:
javax.swing.table.JTableHeader

resizeAndRepaint

protected void resizeAndRepaint()
Equivalent to revalidate followed by repaint.


getCellEditor

public javax.swing.table.TableCellEditor getCellEditor()
Enabled: Returns the cell editor.

Returns:
the TableCellEditor that does the editing
See Also:
cellEditor

setCellEditor

public void setCellEditor(javax.swing.table.TableCellEditor anEditor)
Enabled: Sets the cellEditor variable.

Parameters:
anEditor - the TableCellEditor that does the editing
See Also:
cellEditor

setEditingColumn

public void setEditingColumn(int aColumn)
Enabled: Sets the editingColumn variable.

Parameters:
aColumn - the column of the cell to be edited
See Also:
editingColumn

setEditingRow

public void setEditingRow(int aRow)
Enabled: Sets the editingRow variable.

Parameters:
aRow - the row of the cell to be edited
See Also:
editingRow

getCellRenderer

public javax.swing.table.TableCellRenderer getCellRenderer(int row,
                                                           int column)
Enabled: Returns an appropriate renderer for the cell specified by this row and column. If the TableColumn for this column has a non-null renderer, returns that. If not, finds the class of the data in this column (using getColumnClass) and returns the default renderer for this type of data.

Note: Throughout the table package, the internal implementations always use this method to provide renderers so that this default behavior can be safely overridden by a subclass.

Parameters:
row - the row of the cell to render, where 0 is the first row
column - the column of the cell to render, where 0 is the first column
Returns:
the assigned renderer; if null returns the default renderer for this type of object
See Also:
javax.swing.table.DefaultTableCellRenderer, javax.swing.table.TableColumn#setCellRenderer, setDefaultRenderer(java.lang.Class, javax.swing.table.TableCellRenderer)

prepareRenderer

public Component prepareRenderer(javax.swing.table.TableCellRenderer renderer,
                                 int row,
                                 int column)
Enabled: Prepares the renderer by querying the data model for the value and selection state of the cell at row, column. Returns the component (may be a Component or a JComponent) under the event location.

Note: Throughout the table package, the internal implementations always use this method to prepare renderers so that this default behavior can be safely overridden by a subclass.

Parameters:
renderer - the TableCellRenderer to prepare
row - the row of the cell to render, where 0 is the first row
column - the column of the cell to render, where 0 is the first column
Returns:
the Component under the event location

getCellEditor

public javax.swing.table.TableCellEditor getCellEditor(int row,
                                                       int column)
Enabled: Returns an appropriate editor for the cell specified by row and column. If the TableColumn for this column has a non-null editor, returns that. If not, finds the class of the data in this column (using getColumnClass) and returns the default editor for this type of data.

Note: Throughout the table package, the internal implementations always use this method to provide editors so that this default behavior can be safely overridden by a subclass.

Parameters:
row - the row of the cell to edit, where 0 is the first row
column - the column of the cell to edit, where 0 is the first column
Returns:
the editor for this cell; if null return the default editor for this type of cell
See Also:
DefaultCellEditor

prepareEditor

public Component prepareEditor(javax.swing.table.TableCellEditor editor,
                               int row,
                               int column)
Enabled: Prepares the editor by querying the data model for the value and selection state of the cell at row, column.

Note: Throughout the table package, the internal implementations always use this method to prepare editors so that this default behavior can be safely overridden by a subclass.

Parameters:
editor - the TableCellEditor to set up
row - the row of the cell to edit, where 0 is the first row
column - the column of the cell to edit, where 0 is the first column
Returns:
the Component being edited

removeEditor

public void removeEditor()
Enabled: Discards the editor object and frees the real estate it used for cell rendering.


writeObject

private void writeObject(ObjectOutputStream s)
                  throws IOException
See readObject() and writeObject() in JComponent for more information about serialization in Swing.

Parameters:
s - the ObjectOutputStream in which to write
IOException

readObject

private void readObject(ObjectInputStream s)
                 throws IOException,
                        ClassNotFoundException
Description copied from class: JComponent
We use the ObjectInputStream "registerValidation" callback to update the UI for the entire tree of components after they've all been read in.

Parameters:
s - the ObjectInputStream from which to read
IOException
ClassNotFoundException
See Also:
ReadObjectCallback

compWriteObjectNotify

void compWriteObjectNotify()
Overrides:
compWriteObjectNotify in class JComponent

paramString

protected String paramString()
Returns a string representation of this table. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null.

Overrides:
paramString in class JComponent
Returns:
a string representation of this table

getAccessibleContext

public AccessibleContext getAccessibleContext()
Suppressed: Gets the AccessibleContext associated with this JTable. For tables, the AccessibleContext takes the form of an AccessibleJTable. A new AccessibleJTable instance is created if necessary.

Specified by:
getAccessibleContext in interface Accessible
Overrides:
getAccessibleContext in class JComponent
Returns:
an AccessibleJTable that serves as the AccessibleContext of this JTable


comments?