net.sf.xframe.swing
Class JXTable

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended bynet.sf.xframe.swing.JXTable
All Implemented Interfaces:
javax.accessibility.Accessible, javax.swing.event.CellEditorListener, java.util.EventListener, java.awt.image.ImageObserver, javax.swing.event.ListSelectionListener, java.awt.MenuContainer, javax.swing.Scrollable, java.io.Serializable, javax.swing.event.TableColumnModelListener, javax.swing.event.TableModelListener

public class JXTable
extends javax.swing.JComponent
implements javax.swing.event.TableModelListener, javax.swing.Scrollable, javax.swing.event.TableColumnModelListener, javax.swing.event.ListSelectionListener, javax.swing.event.CellEditorListener, javax.accessibility.Accessible

A table with freezable columns.

The main feature of this table is two allow locking columns while still having a neat user interface. For most of the original methods of class JTable there are delegate methods.

Author:
Kurt Riede
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static int AUTO_RESIZE_ALL_COLUMNS
          During all resize operations, proportionately resize all columns.
static int AUTO_RESIZE_LAST_COLUMN
          During all resize operations, apply adjustments to the last column only.
static int AUTO_RESIZE_NEXT_COLUMN
          When a column is adjusted in the UI, adjust the next column the opposite way.
static int AUTO_RESIZE_OFF
          Do not adjust column widths automatically; use a scrollbar.
static int AUTO_RESIZE_SUBSEQUENT_COLUMNS
          During UI adjustment, change subsequent columns to preserve the total width; this is the default behavior.
static int HORIZONTAL_SCROLLBAR_ALWAYS
          Used to set the horizontal scroll bar policy so that horizontal scrollbars are always displayed.
static int HORIZONTAL_SCROLLBAR_AS_NEEDED
          Used to set the horizontal scroll bar policy so that horizontal scrollbars are displayed only when needed.
static int HORIZONTAL_SCROLLBAR_NEVER
          Used to set the horizontal scroll bar policy so that horizontal scrollbars are never displayed.
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Container
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JXTable()
          Constructs a default JTable that is initialized with a default data model, a default column model, and a default selection model.
JXTable(javax.swing.table.TableModel dm)
          Constructs a JTable that is initialized with dm as the data model, a default column model, and a default selection model.
JXTable(javax.swing.table.TableModel dm, int numFrozenColumns)
          Constructs a JTable that is initialized with dm as the data model, a default column model, and a default selection model.
JXTable(javax.swing.table.TableModel dm, javax.swing.table.TableColumnModel cm)
          Constructs a JTable that is initialized with dm as the data model, cm as the column model, and a default selection model.
JXTable(javax.swing.table.TableModel dm, javax.swing.table.TableColumnModel cm, int numFrozenColumns)
          Constructs a JTable that is initialized with dm as the data model, cm as the column model, and a default selection model.
JXTable(javax.swing.table.TableModel dm, javax.swing.table.TableColumnModel cm, javax.swing.ListSelectionModel sm)
          Constructs a JTable that is initialized with dm as the data model, cm as the column model, and sm as the selection model.
JXTable(javax.swing.table.TableModel dm, javax.swing.table.TableColumnModel cm, javax.swing.ListSelectionModel sm, int numFrozenColumns)
          Constructs a JTable that is initialized with dm as the data model, cm as the column model, and sm as the selection model.
 
Method Summary
 void addColumn(javax.swing.table.TableColumn aColumn)
          Appends aColumn to the end of the array of columns held by this JTable's column model.
 void addColumnSelectionInterval(int index0, int index1)
          Adds the columns from index0 to index1, inclusive, to the current selection.
 void addFrozenColumn(javax.swing.table.TableColumn aColumn)
          Appends aColumn after the currently last frozen column held by this JTable's column model.
 void addMouseListener(java.awt.event.MouseListener l)
          Adds the specified mouse listener to receive mouse events from this component.
 void addMouseMotionListener(java.awt.event.MouseMotionListener l)
          Adds the specified mouse motion listener to receive mouse motion events from this component.
 void addMouseWheelListener(java.awt.event.MouseWheelListener l)
          Adds the specified mouse wheel listener to receive mouse wheel events from this component.
 void addRowSelectionInterval(int index0, int index1)
          Adds the rows from index0 to index1, inclusive, to the current selection.
 void changeSelection(int row, int column, boolean toggle, boolean extend)
          Updates the selection models of the table, depending on the state of the two flags: toggle and extend.
 void clearSelection()
          Deselects all selected columns and rows.
 void columnAdded(javax.swing.event.TableColumnModelEvent e)
          Tells listeners that a column was added to the model.
 int columnAtPoint(java.awt.Point point)
          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(javax.swing.event.ChangeEvent e)
          Tells listeners that a column was moved due to a margin change.
 void columnMoved(javax.swing.event.TableColumnModelEvent e)
          Tells listeners that a column was repositioned.
 void columnRemoved(javax.swing.event.TableColumnModelEvent e)
          Tells listeners that a column was removed from the model.
 void columnSelectionChanged(javax.swing.event.ListSelectionEvent e)
          Tells listeners that the selection model of the TableColumnModel changed.
 int convertColumnIndexToModel(int viewColumnIndex)
          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)
          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()
          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.
 javax.swing.table.JTableHeader createDefaultScrollTableHeader()
          Returns the default table header object for the scrollable table, which is a JTableHeader.
protected  javax.swing.ListSelectionModel createDefaultSelectionModel()
          Returns the default selection model object, which is a DefaultListSelectionModel.
 boolean editCellAt(int row, int column)
          Programmatically starts editing the cell at row and column, if the cell is editable.
 boolean editCellAt(int row, int column, java.util.EventObject e)
          Programmatically starts editing the cell at row and column, if the cell is editable.
 void editingCanceled(javax.swing.event.ChangeEvent e)
          This tells the listeners the editor has canceled editing.
 void editingStopped(javax.swing.event.ChangeEvent e)
          This tells the listeners the editor has ended editing.
protected  JScrollPaneAdjuster getAdjuster()
          Returns the scroll pane adjuster.
 boolean getAutoCreateColumnsFromModel()
          Determines whether the table will create default columns from the model.
 int getAutoResizeMode()
          Returns the auto resize mode of the table.
 javax.swing.table.TableCellEditor getCellEditor()
          Returns the cell editor.
 javax.swing.table.TableCellEditor getCellEditor(int row, int column)
          Returns an appropriate editor for the cell specified by row and column.
 java.awt.Rectangle getCellRect(int row, int column, boolean includeSpacing)
          Returns a rectangle for the cell that lies at the intersection of row and column.
 javax.swing.table.TableCellRenderer getCellRenderer(int row, int column)
          Returns an appropriate renderer for the cell specified by this row and column.
 boolean getCellSelectionEnabled()
          Returns true if both row and column selection models are enabled.
 javax.swing.table.TableColumn getColumn(java.lang.Object identifier)
          Returns the TableColumn object for the column in the table whose identifier is equal to identifier, when compared using equals.
 java.lang.Class getColumnClass(int column)
          Returns the type of the column appearing in the view at column position column.
 int getColumnCount()
          Returns the number of columns in the column model.
 javax.swing.table.TableColumnModel getColumnModel()
           
 java.lang.String getColumnName(int column)
          Returns the name of the column appearing in the view at column position column.
 boolean getColumnSelectionAllowed()
          Returns always false.
 javax.swing.table.TableCellEditor getDefaultEditor(java.lang.Class columnClass)
          Returns the editor to be used when no editor has been set in a TableColumn.
 javax.swing.table.TableCellRenderer getDefaultRenderer(java.lang.Class columnClass)
          Returns the cell renderer to be used when no renderer has been set in a TableColumn.
 boolean getDragEnabled()
          Gets the value of the dragEnabled property.
 int getEditingColumn()
          Returns the index of the column that contains the cell currently being edited.
 int getEditingRow()
          Returns the index of the row that contains the cell currently being edited.
 java.awt.Component getEditorComponent()
          Returns the component that is handling the editing session.
 int getFrozenColumns()
          Returns the number of frozen columns.
 java.awt.Color getGridColor()
          Returns the color used to draw grid lines.
 javax.swing.JScrollBar getHorizontalScrollBar()
          Returns the horizontal scrollbar of the table.
 int getHorizontalScrollBarPolicy()
          Returns the horizontal scroll bar policy value.
 java.awt.Dimension getIntercellSpacing()
          Returns the horizontal and vertical space between cells.
 java.util.EventListener[] getListeners(java.lang.Class listenerType)
          Returns an array of all the objects currently registered as FooListeners upon this Component.
 javax.swing.JTable getLockedTable()
          Returns the internal table for the locked columns.
 javax.swing.table.TableModel getModel()
          Returns the TableModel that provides the data displayed by this JTable.
 java.awt.event.MouseListener[] getMouseListeners()
          Returns an array of all the mouse listeners registered on this component.
 java.awt.event.MouseMotionListener[] getMouseMotionListeners()
          Returns an array of all the mouse motion listeners registered on this component.
 java.awt.event.MouseWheelListener[] getMouseWheelListeners()
          Returns an array of all the mouse wheel listeners registered on this component.
 java.awt.Dimension getPreferredScrollableViewportSize()
          Returns the preferred size of the viewport for this table.
 int getRowCount()
          Returns the number of rows in this table's model.
 int getRowHeight()
          Returns the height of a table row, in pixels.
 int getRowHeight(int row)
          Returns the height, in pixels, of the cells in row.
 int getRowMargin()
          Gets the amount of empty space, in pixels, between cells.
 boolean getRowSelectionAllowed()
          Returns true if rows can be selected.
 int getScrollableBlockIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)
          Returns visibleRect.height or visibleRect.width, depending on this table's orientation.
 boolean getScrollableTracksViewportHeight()
          Returns false to indicate that the height of the viewport does not determine the height of the table.
 boolean getScrollableTracksViewportWidth()
          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(java.awt.Rectangle visibleRect, int orientation, int direction)
          Returns the scroll increment (in pixels) that completely exposes one new row or column (depending on the orientation).
 javax.swing.JScrollPane getScrollPane()
          Returns the underlying scroll pane.
 javax.swing.JTable getScrollTable()
          Returns the internal table for the scrollable columns.
 int getSelectedColumn()
          Returns the index of the first selected column, -1 if no column is selected.
 int getSelectedColumnCount()
          Returns the number of selected columns.
 int[] getSelectedColumns()
          Returns the indices of all selected columns.
 int getSelectedRow()
          Returns the index of the first selected row, -1 if no row is selected.
 int getSelectedRowCount()
          Returns the number of selected rows.
 int[] getSelectedRows()
          Returns the indices of all selected rows.
 java.awt.Color getSelectionBackground()
          Returns the background color for selected cells.
 java.awt.Color getSelectionForeground()
          Returns the foreground color for selected cells.
 javax.swing.ListSelectionModel getSelectionModel()
          Returns the ListSelectionModel that is used to maintain row selection state.
 boolean getShowHorizontalLines()
          Returns true if the table draws horizontal lines between cells, false if it doesn't.
 boolean getShowVerticalLines()
          Returns true if the table draws vertical lines between cells, false if it doesn't.
 boolean getSurrendersFocusOnKeystroke()
          Returns true if the editor should get the focus when keystrokes cause the editor to be activated.
 JXTableHeader getTableHeader()
          Returns the table header.
 javax.swing.TransferHandler getTransferHandler()
          Gets the transferHandler property.
 javax.swing.plaf.TableUI getUI()
          Returns the L&F object that renders this component.
 java.lang.Object getValueAt(int row, int column)
          Returns the cell value at row and column.
 javax.swing.JScrollBar getVerticalScrollBar()
          Returns the vertical scrollbar of the table.
 int getVerticalScrollBarPolicy()
          Returns the vertical scroll bar policy value.
 boolean isCellEditable(int row, int column)
          Returns true if the cell at row and column is editable.
 boolean isCellSelected(int row, int column)
          Returns true if the cell at the specified position is selected.
 boolean isColumnSelected(int column)
          Returns true if the column at the specified index is selected.
 boolean isEditing()
          Returns true if a cell is being edited.
 boolean isRowSelected(int row)
          Returns true if the row at the specified index is selected.
 void moveColumn(int column, int targetColumn)
          Moves the column column to the position currently occupied by the column targetColumn in the view.
protected  int nextRow(javax.swing.JTable table)
          /** Returns the number of the next row in the table relative to the current selection.
 java.awt.Component prepareEditor(javax.swing.table.TableCellEditor editor, int row, int column)
          Prepares the editor by querying the data model for the value and selection state of the cell at row, column.
 java.awt.Component prepareRenderer(javax.swing.table.TableCellRenderer renderer, int row, int column)
          Prepares the renderer by querying the data model for the value and selection state of the cell at row, column.
 void removeColumn(javax.swing.table.TableColumn aColumn)
          Removes aColumn from this JTable's array of columns.
 void removeColumnSelectionInterval(int index0, int index1)
          Deselects the columns from index0 to index1, inclusive.
 void removeEditor()
          Discards the editor object and frees the real estate it used for cell rendering.
 void removeFrozenColumn(javax.swing.table.TableColumn aColumn)
          Removes aColumn from this JXTable's frozen columns.
 void removeMouseListener(java.awt.event.MouseListener l)
          Removes the specified mouse listener so that it no longer receives mouse events from this component.
 void removeMouseMotionListener(java.awt.event.MouseMotionListener l)
          Removes the specified mouse motion listener so that it no longer receives mouse motion events from this component.
 void removeMouseWheelListener(java.awt.event.MouseWheelListener l)
          Removes the specified mouse wheel listener so that it no longer receives mouse wheel events from this component.
 void removeRowSelectionInterval(int index0, int index1)
          Deselects the rows from index0 to index1, inclusive.
 int rowAtPoint(java.awt.Point point)
          Returns the index of the row that point lies in, or -1 if the result is not in the range [0, getRowCount()-1].
 void selectAll()
          Selects all rows, columns, and cells in the table.
 void setAutoCreateColumnsFromModel(boolean autoCreateColumnsFromModel)
          Sets this table's autoCreateColumnsFromModel flag.
 void setAutoResizeMode(int mode)
          Sets the table's auto resize mode when the table is resized.
 void setBackground(java.awt.Color bg)
           
 void setCellEditor(javax.swing.table.TableCellEditor anEditor)
          Sets the cellEditor variable.
 void setCellSelectionEnabled(boolean cellSelectionEnabled)
          Sets whether this table allows both a column selection and a row selection to exist simultaneously.
 void setColumnModel(javax.swing.table.TableColumnModel cm)
          Sets the column model for this table to newModel and registers for listener notifications from the new column model.
 void setColumnSelectionAllowed(boolean b)
          Sets whether the columns in this model can be selected.
 void setColumnSelectionInterval(int index0, int index1)
          Selects the columns from index0 to index1, inclusive.
 void setDefaultEditor(java.lang.Class columnClass, javax.swing.table.TableCellEditor editor)
          Sets a default cell editor to be used if no editor has been set in a TableColumn.
 void setDefaultRenderer(java.lang.Class columnClass, javax.swing.table.TableCellRenderer renderer)
          Sets a default cell renderer to be used if no renderer has been set in a TableColumn.
 void setDragEnabled(boolean b)
          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)
          Sets the editingColumn variable.
 void setEditingRow(int row)
          Sets the editingRow variable.
 void setFont(java.awt.Font f)
           
 void setForeground(java.awt.Color fg)
          Sets the foreground color of this component.
 void setFrozenColumns(int numFrozenColumns)
          Setter method for frozen columns attribute.
 void setGridColor(java.awt.Color gridColor)
          Sets the color used to draw grid lines to gridColor and redisplays.
 void setHeaderBackground(java.awt.Color bg)
          Sets the background color of this component.
 void setHeaderBorder(javax.swing.border.Border border)
          Sets the border of the table header.
 void setHeaderFont(java.awt.Font font)
          Sets the font for the table header.
 void setHorizontalScrollBarPolicy(int policy)
          Determines when the horizontal scrollbar appears in the scrollpane.
 void setIntercellSpacing(java.awt.Dimension intercellSpacing)
          Sets the rowMargin and the columnMargin -- the height and width of the space between cells -- to intercellSpacing.
 void setModel(javax.swing.table.TableModel dataModel)
          Sets the data model for this table to newModel and registers with it for listener notifications from the new data model.
 void setOpaque(boolean isOpaque)
           
 void setPreferredScrollableViewportSize(java.awt.Dimension size)
          Sets the preferred size of the viewport for this table.
 void setReorderingAllowed(boolean reorderingAllowed)
          Sets whether the user can drag column headers to reorder columns.
 void setResizingAllowed(boolean resizingAllowed)
          Sets whether the user can resize columns by dragging between headers.
 void setRowHeight(int rowHeight)
          Sets the height, in pixels, of all cells to rowHeight, revalidates, and repaints.
 void setRowHeight(int row, int rowHeight)
          Sets the height for row to rowHeight, revalidates, and repaints.
 void setRowMargin(int rowMargin)
          Sets the amount of empty space between cells in adjacent rows.
 void setRowSelectionAllowed(boolean rowSelectionAllowed)
          Sets whether the rows in this model can be selected.
 void setRowSelectionInterval(int index0, int index1)
          Selects the rows from index0 to index1, inclusive.
 void setScrollPaneUI(javax.swing.plaf.ScrollPaneUI scrollpaneui)
           
 void setSelectionBackground(java.awt.Color selectionBackground)
          Sets the background color for selected cells.
 void setSelectionForeground(java.awt.Color selectionForeground)
          Sets the foreground color for selected cells.
 void setSelectionMode(int selectionMode)
          Sets the table's selection mode to allow only single selections, a single contiguous interval, or multiple intervals.
 void setSelectionModel(javax.swing.ListSelectionModel newModel)
          Sets the row selection model for this table to newModel and registers for listener notifications from the new selection model.
 void setShowGrid(boolean showGrid)
          Sets whether the table draws grid lines around cells.
 void setShowHorizontalLines(boolean showHorizontalLines)
          Sets whether the table draws horizontal lines between cells.
 void setShowVerticalLines(boolean showVerticalLines)
          Sets whether the table draws vertical lines between cells.
 void setSurrendersFocusOnKeystroke(boolean surrendersFocusOnKeystroke)
          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 setTableFont(java.awt.Font font)
          Sets the font for this component.
 void setTableHeader(JXTableHeader newHeader)
          Sets the tableHeader working with this JTable to newHeader.
 void setTransferHandler(javax.swing.TransferHandler newHandler)
          Sets the transferHandler property, which is null if the component does not support data transfer operations.
 void setUI(javax.swing.plaf.TableUI tableUi)
          Sets the L&F object that renders this component and repaints.
 void setValueAt(java.lang.Object aValue, int row, int column)
          Sets the value for the cell in the table model at row and column.
 void setVerticalScrollBarPolicy(int policy)
          Determines when the vertical scrollbar appears in the scrollpane.
 void sizeColumnsToFit(boolean lastColumnOnly)
          Deprecated. As of Swing version 1.0.3, replaced by doLayout().
 void sizeColumnsToFit(int resizingColumn)
          Obsolete as of Java 2 platform v1.4.
 void tableChanged(javax.swing.event.TableModelEvent e)
          This fine grain notification tells listeners the exact range of cells, rows, or columns that changed.
 void valueChanged(javax.swing.event.ListSelectionEvent e)
          Called whenever the value of the selection changes.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, 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, 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, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.accessibility.Accessible
getAccessibleContext
 

Field Detail

HORIZONTAL_SCROLLBAR_AS_NEEDED

public static final int HORIZONTAL_SCROLLBAR_AS_NEEDED
Used to set the horizontal scroll bar policy so that horizontal scrollbars are displayed only when needed.

See Also:
Constant Field Values

HORIZONTAL_SCROLLBAR_NEVER

public static final int HORIZONTAL_SCROLLBAR_NEVER
Used to set the horizontal scroll bar policy so that horizontal scrollbars are never displayed.

See Also:
Constant Field Values

HORIZONTAL_SCROLLBAR_ALWAYS

public static final int HORIZONTAL_SCROLLBAR_ALWAYS
Used to set the horizontal scroll bar policy so that horizontal scrollbars are always displayed.

See Also:
Constant Field Values

AUTO_RESIZE_OFF

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

See Also:
Constant Field Values

AUTO_RESIZE_NEXT_COLUMN

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

See Also:
Constant Field Values

AUTO_RESIZE_SUBSEQUENT_COLUMNS

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

See Also:
Constant Field Values

AUTO_RESIZE_LAST_COLUMN

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

See Also:
Constant Field Values

AUTO_RESIZE_ALL_COLUMNS

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

See Also:
Constant Field Values
Constructor Detail

JXTable

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


JXTable

public JXTable(javax.swing.table.TableModel dm)
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

JXTable

public JXTable(javax.swing.table.TableModel dm,
               int numFrozenColumns)
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
numFrozenColumns - the initial number of frozen columns

JXTable

public JXTable(javax.swing.table.TableModel dm,
               javax.swing.table.TableColumnModel cm)
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

JXTable

public JXTable(javax.swing.table.TableModel dm,
               javax.swing.table.TableColumnModel cm,
               int numFrozenColumns)
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
numFrozenColumns - the initial number of frozen columns

JXTable

public JXTable(javax.swing.table.TableModel dm,
               javax.swing.table.TableColumnModel cm,
               javax.swing.ListSelectionModel sm)
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

JXTable

public JXTable(javax.swing.table.TableModel dm,
               javax.swing.table.TableColumnModel cm,
               javax.swing.ListSelectionModel sm,
               int numFrozenColumns)
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
numFrozenColumns - the initial number of frozen columns
Method Detail

getScrollPane

public javax.swing.JScrollPane getScrollPane()
Returns the underlying scroll pane.

Returns:
the underlying scroll pane

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:
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:
DefaultTableColumnModel

createDefaultSelectionModel

protected javax.swing.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:
DefaultListSelectionModel

createDefaultScrollTableHeader

public javax.swing.table.JTableHeader createDefaultScrollTableHeader()
Returns the default table header object for the scrollable table, 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:
JTableHeader, JXTableHeader

nextRow

protected int nextRow(javax.swing.JTable table)
/** Returns the number of the next row in the table relative to the current selection. If the selection is in the last row, the next row is the first row.

Parameters:
table - a JTable for row calculation
Returns:
row number of next row

getLockedTable

public final javax.swing.JTable getLockedTable()
Returns the internal table for the locked columns.

Returns:
the locked table

getScrollTable

public final javax.swing.JTable getScrollTable()
Returns the internal table for the scrollable columns.

Returns:
the scrollable table

getFrozenColumns

public final int getFrozenColumns()
Returns the number of frozen columns.

Returns:
number of frozen columns

setFrozenColumns

public final void setFrozenColumns(int numFrozenColumns)
Setter method for frozen columns attribute.

Changing the number frozen column results in rearranging the columns within the fixed-column and the scrollable table.

Parameters:
numFrozenColumns - of frozen columns

setHeaderBackground

public void setHeaderBackground(java.awt.Color bg)
Sets the background color of this component.

Parameters:
bg - the desired background Color

setHeaderBorder

public void setHeaderBorder(javax.swing.border.Border border)
Sets the border of the table header.

Parameters:
border - the border to be rendered for this component

setHeaderFont

public void setHeaderFont(java.awt.Font font)
Sets the font for the table header.

Parameters:
font - the desired Font for this component

setReorderingAllowed

public void setReorderingAllowed(boolean reorderingAllowed)
Sets whether the user can drag column headers to reorder columns.

Parameters:
reorderingAllowed - true if the table view should allow reordering; otherwise false

setResizingAllowed

public void setResizingAllowed(boolean resizingAllowed)
Sets whether the user can resize columns by dragging between headers.

Parameters:
resizingAllowed - true if table view should allow resizing

setTableFont

public void setTableFont(java.awt.Font font)
Sets the font for this component.

Parameters:
font - the desired Font for this component

setForeground

public void setForeground(java.awt.Color fg)
Sets the foreground color of this component.

Parameters:
fg - the desired foreground Color

setGridColor

public void setGridColor(java.awt.Color gridColor)
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

setSelectionBackground

public void setSelectionBackground(java.awt.Color selectionBackground)
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.

Parameters:
selectionBackground - the Color to use for the background of selected cells

setSelectionForeground

public void setSelectionForeground(java.awt.Color selectionForeground)
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.

Parameters:
selectionForeground - the Color to use in the foreground

setShowGrid

public void setShowGrid(boolean showGrid)
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

setShowHorizontalLines

public void setShowHorizontalLines(boolean showHorizontalLines)
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

setShowVerticalLines

public void setShowVerticalLines(boolean showVerticalLines)
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

changeSelection

public void changeSelection(int row,
                            int column,
                            boolean toggle,
                            boolean extend)
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:
row - affects the selection at row
column - affects the selection at column
toggle - see description above
extend - if true, extend the current selection

editCellAt

public boolean editCellAt(int row,
                          int column)
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

getColumnName

public java.lang.String getColumnName(int column)
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

getEditingColumn

public int getEditingColumn()
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

getEditingRow

public int getEditingRow()
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

getGridColor

public java.awt.Color getGridColor()
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)

getRowSelectionAllowed

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

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

getSelectedRow

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

Returns:
the index of the first selected row

getSelectedRowCount

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

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

getSelectedRows

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

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

getSelectionModel

public javax.swing.ListSelectionModel getSelectionModel()
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

getValueAt

public java.lang.Object getValueAt(int row,
                                   int column)
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(java.lang.Object aValue,
                       int row,
                       int column)
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)

convertColumnIndexToModel

public int convertColumnIndexToModel(int viewColumnIndex)
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)
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)

isCellEditable

public boolean isCellEditable(int row,
                              int column)
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)

isCellSelected

public boolean isCellSelected(int row,
                              int column)
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

isEditing

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

Returns:
true if the table is editing a cell

isRowSelected

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

Parameters:
row - the row being queried
Returns:
true if the row at index row is selected, where 0 is the first row

setEditingRow

public void setEditingRow(int row)
Sets the editingRow variable.

Parameters:
row - the row of the cell to be edited

setSelectionMode

public void setSelectionMode(int selectionMode)
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. The following selectionMode values are allowed:

Parameters:
selectionMode - an integer specifying the type of selections that are permissible

getModel

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

Returns:
the TableModel that provides the data displayed by this JTable

setRowSelectionAllowed

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

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

addColumn

public void addColumn(javax.swing.table.TableColumn aColumn)
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)

addRowSelectionInterval

public void addRowSelectionInterval(int index0,
                                    int index1)
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

clearSelection

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


editCellAt

public boolean editCellAt(int row,
                          int column,
                          java.util.EventObject e)
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

getAutoCreateColumnsFromModel

public boolean getAutoCreateColumnsFromModel()
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)

getCellEditor

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

Returns:
the TableCellEditor that does the editing

getCellEditor

public javax.swing.table.TableCellEditor getCellEditor(int row,
                                                       int column)
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

getCellRenderer

public javax.swing.table.TableCellRenderer getCellRenderer(int row,
                                                           int column)
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:
TableColumn.setCellRenderer(javax.swing.table.TableCellRenderer), setDefaultRenderer(java.lang.Class, javax.swing.table.TableCellRenderer)

getCellSelectionEnabled

public boolean getCellSelectionEnabled()
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)

getColumn

public javax.swing.table.TableColumn getColumn(java.lang.Object identifier)
                                        throws java.lang.IllegalArgumentException
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
Throws:
java.lang.IllegalArgumentException - if identifier is null or no TableColumn has this identifier

getColumnClass

public java.lang.Class getColumnClass(int column)
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

getColumnCount

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

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

getColumnSelectionAllowed

public boolean getColumnSelectionAllowed()
Returns always false.

Returns:
true if columns can be selected, otherwise false

getDefaultEditor

public javax.swing.table.TableCellEditor getDefaultEditor(java.lang.Class columnClass)
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)

getDefaultRenderer

public javax.swing.table.TableCellRenderer getDefaultRenderer(java.lang.Class columnClass)
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)

getDragEnabled

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

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

getEditorComponent

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

Returns:
Component handling editing session

getIntercellSpacing

public java.awt.Dimension getIntercellSpacing()
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)

getPreferredScrollableViewportSize

public java.awt.Dimension getPreferredScrollableViewportSize()
Returns the preferred size of the viewport for this table.

Specified by:
getPreferredScrollableViewportSize in interface javax.swing.Scrollable
Returns:
a Dimension object containing the preferredSize of the JViewport which displays this table

getRowCount

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

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

getRowHeight

public int getRowHeight()
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)

getRowHeight

public int getRowHeight(int row)
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

getRowMargin

public int getRowMargin()
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)

getScrollableBlockIncrement

public int getScrollableBlockIncrement(java.awt.Rectangle visibleRect,
                                       int orientation,
                                       int direction)
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 javax.swing.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)

getScrollableTracksViewportHeight

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

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

getScrollableTracksViewportWidth

public boolean getScrollableTracksViewportWidth()
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 javax.swing.Scrollable
Returns:
false if autoResizeMode is set to AUTO_RESIZE_OFF, otherwise returns true
See Also:
Scrollable.getScrollableTracksViewportWidth()

getScrollableUnitIncrement

public int getScrollableUnitIncrement(java.awt.Rectangle visibleRect,
                                      int orientation,
                                      int direction)
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 javax.swing.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)

getSelectionBackground

public java.awt.Color getSelectionBackground()
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)

getSelectionForeground

public java.awt.Color getSelectionForeground()
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)

getShowHorizontalLines

public boolean getShowHorizontalLines()
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()
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)

getSurrendersFocusOnKeystroke

public boolean getSurrendersFocusOnKeystroke()
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)

moveColumn

public void moveColumn(int column,
                       int targetColumn)
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

prepareRenderer

public java.awt.Component prepareRenderer(javax.swing.table.TableCellRenderer renderer,
                                          int row,
                                          int column)
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 TODO handle the renderer correctly across the KTables

removeColumn

public void removeColumn(javax.swing.table.TableColumn aColumn)
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)

removeColumnSelectionInterval

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

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

removeEditor

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


removeRowSelectionInterval

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

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

rowAtPoint

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

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]

selectAll

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


setAutoCreateColumnsFromModel

public void setAutoCreateColumnsFromModel(boolean autoCreateColumnsFromModel)
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()

setAutoResizeMode

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

Parameters:
mode - One of 5 legal values: AUTO_RESIZE_OFF, AUTO_RESIZE_NEXT_COLUMN, AUTO_RESIZE_SUBSEQUENT_COLUMNS, AUTO_RESIZE_LAST_COLUMN, AUTO_RESIZE_ALL_COLUMNS

setCellEditor

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

Parameters:
anEditor - the TableCellEditor that does the editing

setCellSelectionEnabled

public void setCellSelectionEnabled(boolean cellSelectionEnabled)
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)

setDefaultEditor

public void setDefaultEditor(java.lang.Class columnClass,
                             javax.swing.table.TableCellEditor editor)
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(int, int), getDefaultEditor(java.lang.Class), setDefaultRenderer(java.lang.Class, javax.swing.table.TableCellRenderer)

setDefaultRenderer

public void setDefaultRenderer(java.lang.Class columnClass,
                               javax.swing.table.TableCellRenderer renderer)
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)

setDragEnabled

public void setDragEnabled(boolean b)
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 dragEnabled property is false.

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:
JDK 1.4
See Also:
getDragEnabled()

setEditingColumn

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

Parameters:
aColumn - the column of the cell to be edited

setIntercellSpacing

public void setIntercellSpacing(java.awt.Dimension intercellSpacing)
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()

setModel

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

Parameters:
dataModel - the new data source for this table
See Also:
getModel()

setPreferredScrollableViewportSize

public void setPreferredScrollableViewportSize(java.awt.Dimension size)
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()

setRowHeight

public void setRowHeight(int rowHeight)
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()

setRowHeight

public void setRowHeight(int row,
                         int rowHeight)
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

setRowMargin

public void setRowMargin(int rowMargin)
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()

setRowSelectionInterval

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

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

setSelectionModel

public void setSelectionModel(javax.swing.ListSelectionModel newModel)
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()

setSurrendersFocusOnKeystroke

public void setSurrendersFocusOnKeystroke(boolean surrendersFocusOnKeystroke)
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()

sizeColumnsToFit

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

Sizes the table columns to fit the available space.

Parameters:
lastColumnOnly -
See Also:
Container.doLayout()

sizeColumnsToFit

public void sizeColumnsToFit(int resizingColumn)
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:
Container.doLayout()

getTableHeader

public JXTableHeader getTableHeader()
Returns the table header.

Returns:
table header

setFont

public void setFont(java.awt.Font f)
See Also:
JComponent.setFont(java.awt.Font)

setColumnSelectionAllowed

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

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

getHorizontalScrollBar

public javax.swing.JScrollBar getHorizontalScrollBar()
Returns the horizontal scrollbar of the table.

Returns:
the horizontal scrollbar

getVerticalScrollBar

public javax.swing.JScrollBar getVerticalScrollBar()
Returns the vertical scrollbar of the table.

Returns:
the vertical scrollbar

setHorizontalScrollBarPolicy

public void setHorizontalScrollBarPolicy(int policy)
Determines when the horizontal scrollbar appears in the scrollpane. The options are:

Parameters:
policy - one of the three values listed above
See Also:
getHorizontalScrollBarPolicy()

getHorizontalScrollBarPolicy

public int getHorizontalScrollBarPolicy()
Returns the horizontal scroll bar policy value.

Returns:
the horizontalScrollBarPolicy property
See Also:
setHorizontalScrollBarPolicy(int)

setVerticalScrollBarPolicy

public void setVerticalScrollBarPolicy(int policy)
                                throws java.lang.IllegalArgumentException
Determines when the vertical scrollbar appears in the scrollpane. Legal values are:

Parameters:
policy - one of the three values listed above
Throws:
java.lang.IllegalArgumentException - if policy is not one of the legal values shown above
See Also:
getVerticalScrollBarPolicy()

getVerticalScrollBarPolicy

public int getVerticalScrollBarPolicy()
Returns the vertical scroll bar policy value.

Returns:
the verticalScrollBarPolicy property
See Also:
setVerticalScrollBarPolicy(int)

getColumnModel

public javax.swing.table.TableColumnModel getColumnModel()
Returns:
the table column model

setColumnModel

public void setColumnModel(javax.swing.table.TableColumnModel cm)
                    throws java.lang.IllegalArgumentException
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:
cm - the new data source for this table
Throws:
java.lang.IllegalArgumentException - if columnModel is null
See Also:
getColumnModel()

tableChanged

public void tableChanged(javax.swing.event.TableModelEvent e)
This fine grain notification tells listeners the exact range of cells, rows, or columns that changed.

Specified by:
tableChanged in interface javax.swing.event.TableModelListener
Parameters:
e - a tableModelEvent

columnMarginChanged

public void columnMarginChanged(javax.swing.event.ChangeEvent e)
Tells listeners that a column was moved due to a margin change.

Specified by:
columnMarginChanged in interface javax.swing.event.TableColumnModelListener
Parameters:
e - a ChangeEvent

columnSelectionChanged

public void columnSelectionChanged(javax.swing.event.ListSelectionEvent e)
Tells listeners that the selection model of the TableColumnModel changed.

Specified by:
columnSelectionChanged in interface javax.swing.event.TableColumnModelListener
Parameters:
e - a ListSelectionEvent

columnAdded

public void columnAdded(javax.swing.event.TableColumnModelEvent e)
Tells listeners that a column was added to the model.

Specified by:
columnAdded in interface javax.swing.event.TableColumnModelListener
Parameters:
e - a TableColumnModelEvent

columnMoved

public void columnMoved(javax.swing.event.TableColumnModelEvent e)
Tells listeners that a column was repositioned.

Specified by:
columnMoved in interface javax.swing.event.TableColumnModelListener
Parameters:
e - a TableColumnModelEvent

columnRemoved

public void columnRemoved(javax.swing.event.TableColumnModelEvent e)
Tells listeners that a column was removed from the model.

Specified by:
columnRemoved in interface javax.swing.event.TableColumnModelListener
Parameters:
e - a TableColumnModelEvent

valueChanged

public void valueChanged(javax.swing.event.ListSelectionEvent e)
Called whenever the value of the selection changes.

Specified by:
valueChanged in interface javax.swing.event.ListSelectionListener
Parameters:
e - the event that characterizes the change.

editingCanceled

public void editingCanceled(javax.swing.event.ChangeEvent e)
This tells the listeners the editor has canceled editing.

Specified by:
editingCanceled in interface javax.swing.event.CellEditorListener
Parameters:
e - a ChangeEvent

editingStopped

public void editingStopped(javax.swing.event.ChangeEvent e)
This tells the listeners the editor has ended editing.

Specified by:
editingStopped in interface javax.swing.event.CellEditorListener
Parameters:
e - a ChangeEvent

setTableHeader

public void setTableHeader(JXTableHeader newHeader)
Sets the tableHeader working with this JTable to newHeader. It is legal to have a null tableHeader.

Parameters:
newHeader - new tableHeader
See Also:
getTableHeader()

getAutoResizeMode

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

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

createDefaultColumnsFromModel

public void createDefaultColumnsFromModel()
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()

setColumnSelectionInterval

public void setColumnSelectionInterval(int index0,
                                       int index1)
                                throws java.lang.IllegalArgumentException
Selects the columns from index0 to index1, inclusive.

Parameters:
index0 - one end of the interval
index1 - the other end of the interval
Throws:
java.lang.IllegalArgumentException - if index0 or index1 lie outside [0, getColumnCount()-1]

addColumnSelectionInterval

public void addColumnSelectionInterval(int index0,
                                       int index1)
                                throws java.lang.IllegalArgumentException
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
Throws:
java.lang.IllegalArgumentException - if index0 or index1 lie outside [0, getColumnCount()-1]

getSelectedColumn

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

Returns:
the index of the first selected column

getSelectedColumns

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

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

getSelectedColumnCount

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

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

isColumnSelected

public boolean isColumnSelected(int column)
                         throws java.lang.IllegalArgumentException
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
Throws:
java.lang.IllegalArgumentException - if column is not in the valid range

columnAtPoint

public int columnAtPoint(java.awt.Point point)
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)

getCellRect

public java.awt.Rectangle getCellRect(int row,
                                      int column,
                                      boolean includeSpacing)
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

getUI

public javax.swing.plaf.TableUI getUI()
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 tableUi)
Sets the L&F object that renders this component and repaints.

Parameters:
tableUi - the TableUI L&F object
See Also:
JTable.setUI(javax.swing.plaf.TableUI)

prepareEditor

public java.awt.Component prepareEditor(javax.swing.table.TableCellEditor editor,
                                        int row,
                                        int column)
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

addFrozenColumn

public void addFrozenColumn(javax.swing.table.TableColumn aColumn)
Appends aColumn after the currently last frozen column 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().

The number of frozenn column is increased by one with a call to this method.

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)

removeFrozenColumn

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

The number of frozenn column is decreased by one with a call to this method.

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

getAdjuster

protected JScrollPaneAdjuster getAdjuster()
Returns the scroll pane adjuster.

Returns:
the scroll pane adjuster

setTransferHandler

public void setTransferHandler(javax.swing.TransferHandler newHandler)
Sets the transferHandler property, which is null if the component does not support data transfer operations.

If newHandler is not null, and the system property suppressSwingDropSupport is not true, this will install a DropTarget on the JComponent. The default for the system property is false, so that a DropTarget will be added.

Parameters:
newHandler - mechanism for transfer of data to and from the component
See Also:
TransferHandler, JComponent.setTransferHandler(javax.swing.TransferHandler)

getTransferHandler

public javax.swing.TransferHandler getTransferHandler()
Gets the transferHandler property.

Returns:
the value of the transferHandler property
See Also:
TransferHandler, setTransferHandler(javax.swing.TransferHandler)

addMouseListener

public void addMouseListener(java.awt.event.MouseListener l)
Adds the specified mouse listener to receive mouse events from this component. If listener l is null, no exception is thrown and no action is performed.

Parameters:
l - the mouse listener
See Also:
MouseEvent, MouseListener, removeMouseListener(java.awt.event.MouseListener), getMouseListeners(), Component.addMouseListener(java.awt.event.MouseListener)

removeMouseListener

public void removeMouseListener(java.awt.event.MouseListener l)
Removes the specified mouse listener so that it no longer receives mouse events from this component. This method performs no function, nor does it throw an exception, if the listener specified by the argument was not previously added to this component. If listener l is null, no exception is thrown and no action is performed.

Parameters:
l - the mouse listener
See Also:
MouseEvent, MouseListener, addMouseListener(java.awt.event.MouseListener), getMouseListeners(), Component.removeMouseListener(java.awt.event.MouseListener)

getMouseListeners

public java.awt.event.MouseListener[] getMouseListeners()
Returns an array of all the mouse listeners registered on this component.

Returns:
all of this component's MouseListeners or an empty array if no mouse listeners are currently registered
Since:
1.4
See Also:
addMouseListener(java.awt.event.MouseListener), removeMouseListener(java.awt.event.MouseListener), Component.getMouseListeners()

addMouseMotionListener

public void addMouseMotionListener(java.awt.event.MouseMotionListener l)
Adds the specified mouse motion listener to receive mouse motion events from this component. If listener l is null, no exception is thrown and no action is performed.

Parameters:
l - the mouse motion listener
See Also:
MouseEvent, MouseMotionListener, removeMouseMotionListener(java.awt.event.MouseMotionListener), getMouseMotionListeners(), Component.addMouseMotionListener(java.awt.event.MouseMotionListener)

removeMouseMotionListener

public void removeMouseMotionListener(java.awt.event.MouseMotionListener l)
Removes the specified mouse motion listener so that it no longer receives mouse motion events from this component. This method performs no function, nor does it throw an exception, if the listener specified by the argument was not previously added to this component. If listener l is null, no exception is thrown and no action is performed.

Parameters:
l - the mouse motion listener
See Also:
MouseEvent, MouseMotionListener, addMouseMotionListener(java.awt.event.MouseMotionListener), getMouseMotionListeners(), Component.removeMouseMotionListener(java.awt.event.MouseMotionListener)

getMouseMotionListeners

public java.awt.event.MouseMotionListener[] getMouseMotionListeners()
Returns an array of all the mouse motion listeners registered on this component.

Returns:
all of this component's MouseMotionListeners or an empty array if no mouse motion listeners are currently registered
See Also:
addMouseMotionListener(java.awt.event.MouseMotionListener), removeMouseMotionListener(java.awt.event.MouseMotionListener), Component.getMouseMotionListeners()

addMouseWheelListener

public void addMouseWheelListener(java.awt.event.MouseWheelListener l)
Adds the specified mouse wheel listener to receive mouse wheel events from this component. Containers also receive mouse wheel events from sub-components. If l is null, no exception is thrown and no action is performed.

Parameters:
l - the mouse wheel listener.
See Also:
MouseWheelEvent, MouseWheelListener, removeMouseWheelListener(java.awt.event.MouseWheelListener), getMouseWheelListeners(), Component.addMouseWheelListener(java.awt.event.MouseWheelListener)

removeMouseWheelListener

public void removeMouseWheelListener(java.awt.event.MouseWheelListener l)
Removes the specified mouse wheel listener so that it no longer receives mouse wheel events from this component. This method performs no function, nor does it throw an exception, if the listener specified by the argument was not previously added to this component. If l is null, no exception is thrown and no action is performed.

Parameters:
l - the mouse wheel listener.
See Also:
MouseWheelEvent, MouseWheelListener, addMouseWheelListener(java.awt.event.MouseWheelListener), getMouseWheelListeners(), Component.removeMouseWheelListener(java.awt.event.MouseWheelListener)

getMouseWheelListeners

public java.awt.event.MouseWheelListener[] getMouseWheelListeners()
Returns an array of all the mouse wheel listeners registered on this component.

Returns:
all of this component's MouseWheelListeners or an empty array if no mouse wheel listeners are currently registered
See Also:
addMouseWheelListener(java.awt.event.MouseWheelListener), removeMouseWheelListener(java.awt.event.MouseWheelListener), Component.getMouseWheelListeners()

getListeners

public java.util.EventListener[] getListeners(java.lang.Class listenerType)
Returns an array of all the objects currently registered as FooListeners upon this Component. FooListeners are registered using the addFooListener method.

You can specify the listenerType argument with a class literal, such as FooListener.class. For example, you can query a Component c for its mouse listeners with the following code:

MouseListener[] mls = (MouseListener[])(c.getListeners(MouseListener.class));
If no such listeners exist, this method returns an empty array.

Parameters:
listenerType - the type of listeners requested; this parameter should specify an interface that descends from java.util.EventListener
Returns:
an array of all objects registered as FooListeners on this component, or an empty array if no such listeners have been added
See Also:
getMouseListeners()

setBackground

public void setBackground(java.awt.Color bg)
See Also:
JComponent.setBackground(java.awt.Color)

setOpaque

public void setOpaque(boolean isOpaque)
See Also:
JComponent.setOpaque(boolean)

setScrollPaneUI

public void setScrollPaneUI(javax.swing.plaf.ScrollPaneUI scrollpaneui)
See Also:
JScrollPane.setUI(javax.swing.plaf.ScrollPaneUI)


Copyright © 2004-2005 xframe. All Rights Reserved.