|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
net.sf.xframe.swing.JXTable
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.
| 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 |
public static final int HORIZONTAL_SCROLLBAR_AS_NEEDED
public static final int HORIZONTAL_SCROLLBAR_NEVER
public static final int HORIZONTAL_SCROLLBAR_ALWAYS
public static final int AUTO_RESIZE_OFF
public static final int AUTO_RESIZE_NEXT_COLUMN
public static final int AUTO_RESIZE_SUBSEQUENT_COLUMNS
public static final int AUTO_RESIZE_LAST_COLUMN
public static final int AUTO_RESIZE_ALL_COLUMNS
| Constructor Detail |
public JXTable()
JTable that is initialized with a default
data model, a default column model, and a default selection
model.
public JXTable(javax.swing.table.TableModel dm)
JTable that is initialized with
dm as the data model, a default column model,
and a default selection model.
dm - the data model for the table
public JXTable(javax.swing.table.TableModel dm,
int numFrozenColumns)
JTable that is initialized with
dm as the data model, a default column model,
and a default selection model.
dm - the data model for the tablenumFrozenColumns - the initial number of frozen columns
public JXTable(javax.swing.table.TableModel dm,
javax.swing.table.TableColumnModel cm)
JTable that is initialized with
dm as the data model, cm
as the column model, and a default selection model.
dm - the data model for the tablecm - the column model for the table
public JXTable(javax.swing.table.TableModel dm,
javax.swing.table.TableColumnModel cm,
int numFrozenColumns)
JTable that is initialized with
dm as the data model, cm
as the column model, and a default selection model.
dm - the data model for the tablecm - the column model for the tablenumFrozenColumns - the initial number of frozen columns
public JXTable(javax.swing.table.TableModel dm,
javax.swing.table.TableColumnModel cm,
javax.swing.ListSelectionModel sm)
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.
dm - the data model for the tablecm - the column model for the tablesm - the row selection model for the table
public JXTable(javax.swing.table.TableModel dm,
javax.swing.table.TableColumnModel cm,
javax.swing.ListSelectionModel sm,
int numFrozenColumns)
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.
dm - the data model for the tablecm - the column model for the tablesm - the row selection model for the tablenumFrozenColumns - the initial number of frozen columns| Method Detail |
public javax.swing.JScrollPane getScrollPane()
protected javax.swing.table.TableModel createDefaultDataModel()
DefaultTableModel. A subclass can override this
method to return a different table model object.
DefaultTableModelprotected javax.swing.table.TableColumnModel createDefaultColumnModel()
DefaultTableColumnModel. A subclass can override this
method to return a different column model object.
DefaultTableColumnModelprotected javax.swing.ListSelectionModel createDefaultSelectionModel()
DefaultListSelectionModel. A subclass can override this
method to return a different selection model object.
DefaultListSelectionModelpublic javax.swing.table.JTableHeader createDefaultScrollTableHeader()
JTableHeader. A subclass can override this
method to return a different table header object.
JTableHeader,
JXTableHeaderprotected int nextRow(javax.swing.JTable table)
table - a JTable for row calculation
public final javax.swing.JTable getLockedTable()
public final javax.swing.JTable getScrollTable()
public final int getFrozenColumns()
public final void setFrozenColumns(int numFrozenColumns)
Changing the number frozen column results in rearranging the columns within the fixed-column and the scrollable table.
numFrozenColumns - of frozen columnspublic void setHeaderBackground(java.awt.Color bg)
bg - the desired background Colorpublic void setHeaderBorder(javax.swing.border.Border border)
border - the border to be rendered for this componentpublic void setHeaderFont(java.awt.Font font)
font - the desired Font for this componentpublic void setReorderingAllowed(boolean reorderingAllowed)
reorderingAllowed - true if the table view should allow
reordering; otherwise falsepublic void setResizingAllowed(boolean resizingAllowed)
resizingAllowed - true if table view should allow resizingpublic void setTableFont(java.awt.Font font)
font - the desired Font for this componentpublic void setForeground(java.awt.Color fg)
fg - the desired foreground Colorpublic void setGridColor(java.awt.Color gridColor)
gridColor and redisplays.
The default color is look and feel dependent.
gridColor - the new color of the grid linespublic void setSelectionBackground(java.awt.Color selectionBackground)
The default value of this property is defined by the look and feel implementation.
selectionBackground - the Color to use for the background
of selected cellspublic void setSelectionForeground(java.awt.Color selectionForeground)
The default value of this property is defined by the look and feel implementation.
selectionForeground - the Color to use in the foregroundpublic void setShowGrid(boolean showGrid)
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.
showGrid - true if table view should draw grid linespublic void setShowHorizontalLines(boolean showHorizontalLines)
showHorizontalLines is true it does; if it is false it doesn't.
showHorizontalLines - true if table view should draw horizontal linespublic void setShowVerticalLines(boolean showVerticalLines)
showVerticalLines is true it does; if it is false it doesn't.
showVerticalLines - true if table view should draw vertical lines
public void changeSelection(int row,
int column,
boolean toggle,
boolean extend)
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:
toggle: false, extend: false.
Clear the previous selection and ensure the new cell is selected.
toggle: false, extend: true.
Extend the previous selection to include the specified cell.
toggle: true, extend: false.
If the specified cell is selected, deselect it. If it is not selected, select it.
toggle: true, extend: true.
Leave the selection state as it is, but move the anchor index to the specified location.
row - affects the selection at rowcolumn - affects the selection at columntoggle - see description aboveextend - if true, extend the current selection
public boolean editCellAt(int row,
int column)
row and
column, if the cell is editable. Note that this is
a convenience method for editCellAt(int, int, null).
row - the row to be editedcolumn - the column to be edited
public java.lang.String getColumnName(int column)
column.
column - the column in the view being queried
column
in the view where the first column is column 0public int getEditingColumn()
public int getEditingRow()
public java.awt.Color getGridColor()
setGridColor(java.awt.Color)public boolean getRowSelectionAllowed()
setRowSelectionAllowed(boolean)public int getSelectedRow()
public int getSelectedRowCount()
public int[] getSelectedRows()
getSelectedRow()public javax.swing.ListSelectionModel getSelectionModel()
ListSelectionModel that is used to maintain row
selection state.
null
if row selection is not allowed
public java.lang.Object getValueAt(int row,
int column)
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.
row - the row whose value is to be queriedcolumn - the column whose value is to be queried
public void setValueAt(java.lang.Object aValue,
int row,
int column)
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.
aValue - the new valuerow - the row of the cell to be changedcolumn - the column of the cell to be changedgetValueAt(int, int)public int convertColumnIndexToModel(int viewColumnIndex)
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.
viewColumnIndex - the index of the column in the view
convertColumnIndexToView(int)public int convertColumnIndexToView(int modelColumnIndex)
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.
modelColumnIndex - the index of the column in the model
convertColumnIndexToModel(int)
public boolean isCellEditable(int row,
int column)
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.
row - the row whose value is to be queriedcolumn - the column whose value is to be queried
setValueAt(java.lang.Object, int, int)
public boolean isCellSelected(int row,
int column)
row - the row being queriedcolumn - the column being queried
(row, column) is selected,
where the first row and first column are at index 0public boolean isEditing()
public boolean isRowSelected(int row)
row - the row being queried
row is selected, where 0 is the
first rowpublic void setEditingRow(int row)
editingRow variable.
row - the row of the cell to be editedpublic void setSelectionMode(int selectionMode)
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:
ListSelectionModel.SINGLE_SELECTION
Only one list index can be selected at a time. In this mode the
setSelectionInterval and addSelectionInterval
methods are equivalent, and only the second index argument is used.ListSelectionModel.SINGLE_INTERVAL_SELECTION
One contiguous index interval can be selected at a time. In this mode
setSelectionInterval and addSelectionInterval
are equivalent.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION
In this mode, there's no restriction on what can be selected. This is
the default.
selectionMode - an integer specifying the type of selections
that are permissiblepublic javax.swing.table.TableModel getModel()
TableModel that provides the data displayed by
this JTable.
TableModel that provides the data displayed by
this JTablepublic void setRowSelectionAllowed(boolean rowSelectionAllowed)
rowSelectionAllowed - true if this model will allow row selectiongetRowSelectionAllowed()public void addColumn(javax.swing.table.TableColumn aColumn)
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.
aColumn - the TableColumn to be addedremoveColumn(javax.swing.table.TableColumn)
public void addRowSelectionInterval(int index0,
int index1)
index0 to index1, inclusive, to
the current selection.
index0 - one end of the intervalindex1 - the other end of the intervalpublic void clearSelection()
public boolean editCellAt(int row,
int column,
java.util.EventObject e)
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.
row - the row to be editedcolumn - the column to be editede - event to pass into shouldSelectCell;
note that as of Java 2 platform v1.2, the call to
shouldSelectCell is no longer made
public boolean getAutoCreateColumnsFromModel()
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.
setAutoCreateColumnsFromModel(boolean)public javax.swing.table.TableCellEditor getCellEditor()
TableCellEditor that does the editing
public javax.swing.table.TableCellEditor getCellEditor(int row,
int column)
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.
row - the row of the cell to edit, where 0 is the first rowcolumn - the column of the cell to edit,
where 0 is the first column
null return the default editor for
this type of cell
public javax.swing.table.TableCellRenderer getCellRenderer(int row,
int column)
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.
row - the row of the cell to render, where 0 is the first rowcolumn - the column of the cell to render,
where 0 is the first column
null
returns the default renderer
for this type of objectTableColumn.setCellRenderer(javax.swing.table.TableCellRenderer),
setDefaultRenderer(java.lang.Class, javax.swing.table.TableCellRenderer)public boolean getCellSelectionEnabled()
getRowSelectionAllowed() &&
getColumnSelectionAllowed().
setCellSelectionEnabled(boolean)
public javax.swing.table.TableColumn getColumn(java.lang.Object identifier)
throws java.lang.IllegalArgumentException
TableColumn object for the column in the table
whose identifier is equal to identifier, when compared using
equals.
identifier - the identifier object
TableColumn object that matches the identifier
java.lang.IllegalArgumentException - if identifier is null or no TableColumn
has this identifierpublic java.lang.Class getColumnClass(int column)
column.
column - the column in the view being queried
column
in the view where the first column is column 0public int getColumnCount()
getRowCount(),
removeColumn(javax.swing.table.TableColumn)public boolean getColumnSelectionAllowed()
public javax.swing.table.TableCellEditor getDefaultEditor(java.lang.Class columnClass)
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.
columnClass - return the default cell editor for this columnClass
setDefaultEditor(java.lang.Class, javax.swing.table.TableCellEditor),
getColumnClass(int)public javax.swing.table.TableCellRenderer getDefaultRenderer(java.lang.Class columnClass)
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.
columnClass - return the default cell renderer
for this columnClass
setDefaultRenderer(java.lang.Class, javax.swing.table.TableCellRenderer),
getColumnClass(int)public boolean getDragEnabled()
dragEnabled property.
dragEnabled propertysetDragEnabled(boolean)public java.awt.Component getEditorComponent()
public java.awt.Dimension getIntercellSpacing()
setIntercellSpacing(java.awt.Dimension)public java.awt.Dimension getPreferredScrollableViewportSize()
getPreferredScrollableViewportSize in interface javax.swing.ScrollableDimension object containing the preferredSize of the JViewport
which displays this tablepublic int getRowCount()
getColumnCount()public int getRowHeight()
setRowHeight(int)public int getRowHeight(int row)
row.
row - the row whose height is to be returned
public int getRowMargin()
getIntercellSpacing().height.
setRowMargin(int)
public int getScrollableBlockIncrement(java.awt.Rectangle visibleRect,
int orientation,
int direction)
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.
getScrollableBlockIncrement in interface javax.swing.ScrollablevisibleRect - The view area visible within the viewportorientation - Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.direction - Less than zero to scroll up/left, greater than zero for down/right.
visibleRect.height or
visibleRect.width
per the orientationScrollable.getScrollableBlockIncrement(java.awt.Rectangle, int, int)public boolean getScrollableTracksViewportHeight()
getScrollableTracksViewportHeight in interface javax.swing.ScrollableScrollable.getScrollableTracksViewportHeight()public boolean getScrollableTracksViewportWidth()
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.
getScrollableTracksViewportWidth in interface javax.swing.ScrollableautoResizeMode is set
to AUTO_RESIZE_OFF, otherwise returns trueScrollable.getScrollableTracksViewportWidth()
public int getScrollableUnitIncrement(java.awt.Rectangle visibleRect,
int orientation,
int direction)
This method is called each time the user requests a unit scroll.
getScrollableUnitIncrement in interface javax.swing.ScrollablevisibleRect - the view area visible within the viewportorientation - either SwingConstants.VERTICAL
or SwingConstants.HORIZONTALdirection - less than zero to scroll up/left,
greater than zero for down/right
Scrollable.getScrollableUnitIncrement(java.awt.Rectangle, int, int)public java.awt.Color getSelectionBackground()
Color used for the background of selected list itemssetSelectionBackground(java.awt.Color),
setSelectionForeground(java.awt.Color)public java.awt.Color getSelectionForeground()
Color object for the foreground propertysetSelectionForeground(java.awt.Color),
setSelectionBackground(java.awt.Color)public boolean getShowHorizontalLines()
setShowHorizontalLines(boolean)public boolean getShowVerticalLines()
setShowVerticalLines(boolean)public boolean getSurrendersFocusOnKeystroke()
setSurrendersFocusOnKeystroke(boolean)
public void moveColumn(int column,
int targetColumn)
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.
column - the index of column to be movedtargetColumn - the new index of the column
public java.awt.Component prepareRenderer(javax.swing.table.TableCellRenderer renderer,
int row,
int column)
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.
renderer - the TableCellRenderer to preparerow - the row of the cell to render, where 0 is the first rowcolumn - the column of the cell to render,
where 0 is the first column
Component under the event location
TODO handle the renderer correctly across the KTablespublic void removeColumn(javax.swing.table.TableColumn aColumn)
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.
aColumn - the TableColumn to be removedaddColumn(javax.swing.table.TableColumn)
public void removeColumnSelectionInterval(int index0,
int index1)
index0 to index1, inclusive.
index0 - one end of the intervalindex1 - the other end of the intervalpublic void removeEditor()
public void removeRowSelectionInterval(int index0,
int index1)
index0 to index1, inclusive.
index0 - one end of the intervalindex1 - the other end of the intervalpublic int rowAtPoint(java.awt.Point point)
point lies in,
or -1 if the result is not in the range
[0, getRowCount()-1].
point - the location of interest
point lies in,
or -1 if the result is not in the range
[0, getRowCount()-1]public void selectAll()
public void setAutoCreateColumnsFromModel(boolean autoCreateColumnsFromModel)
autoCreateColumnsFromModel flag.
This method calls createDefaultColumnsFromModel if
autoCreateColumnsFromModel changes from false to true.
autoCreateColumnsFromModel - true if JTable should automatically create columnsgetAutoCreateColumnsFromModel()public void setAutoResizeMode(int mode)
mode - One of 5 legal values:
AUTO_RESIZE_OFF,
AUTO_RESIZE_NEXT_COLUMN,
AUTO_RESIZE_SUBSEQUENT_COLUMNS,
AUTO_RESIZE_LAST_COLUMN,
AUTO_RESIZE_ALL_COLUMNSpublic void setCellEditor(javax.swing.table.TableCellEditor anEditor)
cellEditor variable.
anEditor - the TableCellEditor that does the editingpublic void setCellSelectionEnabled(boolean cellSelectionEnabled)
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.
cellSelectionEnabled - true if simultaneous row and column
selection is allowedgetCellSelectionEnabled(),
isCellSelected(int, int)
public void setDefaultEditor(java.lang.Class columnClass,
javax.swing.table.TableCellEditor editor)
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.
columnClass - set the default cell editor for this columnClasseditor - default cell editor to be used for this columnClassTableModel.isCellEditable(int, int),
getDefaultEditor(java.lang.Class),
setDefaultRenderer(java.lang.Class, javax.swing.table.TableCellRenderer)
public void setDefaultRenderer(java.lang.Class columnClass,
javax.swing.table.TableCellRenderer renderer)
TableColumn. If renderer is null,
removes the default renderer for this column class.
columnClass - set the default cell renderer for this columnClassrenderer - default cell renderer to be used for this columnClassgetDefaultRenderer(java.lang.Class),
setDefaultEditor(java.lang.Class, javax.swing.table.TableCellEditor)public void setDragEnabled(boolean b)
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.
b - the value to set the dragEnabled property togetDragEnabled()public void setEditingColumn(int aColumn)
editingColumn variable.
aColumn - the column of the cell to be editedpublic void setIntercellSpacing(java.awt.Dimension intercellSpacing)
rowMargin and the columnMargin --
the height and width of the space between cells -- to
intercellSpacing.
intercellSpacing - a Dimension
specifying the new width
and height between cellsgetIntercellSpacing()public void setModel(javax.swing.table.TableModel dataModel)
newModel and registers
with it for listener notifications from the new data model.
dataModel - the new data source for this tablegetModel()public void setPreferredScrollableViewportSize(java.awt.Dimension size)
size - a Dimension object specifying the preferredSize of a
JViewport whose view is this tableScrollable.getPreferredScrollableViewportSize()public void setRowHeight(int rowHeight)
rowHeight,
revalidates, and repaints.
The height of the cells will be equal to the row height minus
the row margin.
rowHeight - new row heightgetRowHeight()
public void setRowHeight(int row,
int rowHeight)
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.
row - the row whose height is being changedrowHeight - new row height, in pixelspublic void setRowMargin(int rowMargin)
rowMargin - the number of pixels between cells in a rowgetRowMargin()
public void setRowSelectionInterval(int index0,
int index1)
index0 to index1,
inclusive.
index0 - one end of the intervalindex1 - the other end of the intervalpublic void setSelectionModel(javax.swing.ListSelectionModel newModel)
newModel
and registers for listener notifications from the new selection model.
newModel - the new selection modelgetSelectionModel()public void setSurrendersFocusOnKeystroke(boolean surrendersFocusOnKeystroke)
surrendersFocusOnKeystroke - true if the editor should get the focus
when keystrokes cause the editor to be
activatedgetSurrendersFocusOnKeystroke()public void sizeColumnsToFit(boolean lastColumnOnly)
doLayout().
lastColumnOnly - Container.doLayout()public void sizeColumnsToFit(int resizingColumn)
doLayout() method instead.
resizingColumn - the column whose resizing made this adjustment
necessary or -1 if there is no such columnContainer.doLayout()public JXTableHeader getTableHeader()
public void setFont(java.awt.Font f)
JComponent.setFont(java.awt.Font)public void setColumnSelectionAllowed(boolean b)
b - true if this model will allow column selectiongetColumnSelectionAllowed()public javax.swing.JScrollBar getHorizontalScrollBar()
public javax.swing.JScrollBar getVerticalScrollBar()
public void setHorizontalScrollBarPolicy(int policy)
policy - one of the three values listed abovegetHorizontalScrollBarPolicy()public int getHorizontalScrollBarPolicy()
horizontalScrollBarPolicy propertysetHorizontalScrollBarPolicy(int)
public void setVerticalScrollBarPolicy(int policy)
throws java.lang.IllegalArgumentException
policy - one of the three values listed above
java.lang.IllegalArgumentException - if policy
is not one of the legal values shown abovegetVerticalScrollBarPolicy()public int getVerticalScrollBarPolicy()
verticalScrollBarPolicy propertysetVerticalScrollBarPolicy(int)public javax.swing.table.TableColumnModel getColumnModel()
public void setColumnModel(javax.swing.table.TableColumnModel cm)
throws java.lang.IllegalArgumentException
newModel and registers
for listener notifications from the new column model. Also sets
the column model of the JTableHeader to columnModel.
cm - the new data source for this table
java.lang.IllegalArgumentException - if columnModel is nullgetColumnModel()public void tableChanged(javax.swing.event.TableModelEvent e)
tableChanged in interface javax.swing.event.TableModelListenere - a tableModelEventpublic void columnMarginChanged(javax.swing.event.ChangeEvent e)
columnMarginChanged in interface javax.swing.event.TableColumnModelListenere - a ChangeEventpublic void columnSelectionChanged(javax.swing.event.ListSelectionEvent e)
columnSelectionChanged in interface javax.swing.event.TableColumnModelListenere - a ListSelectionEventpublic void columnAdded(javax.swing.event.TableColumnModelEvent e)
columnAdded in interface javax.swing.event.TableColumnModelListenere - a TableColumnModelEventpublic void columnMoved(javax.swing.event.TableColumnModelEvent e)
columnMoved in interface javax.swing.event.TableColumnModelListenere - a TableColumnModelEventpublic void columnRemoved(javax.swing.event.TableColumnModelEvent e)
columnRemoved in interface javax.swing.event.TableColumnModelListenere - a TableColumnModelEventpublic void valueChanged(javax.swing.event.ListSelectionEvent e)
valueChanged in interface javax.swing.event.ListSelectionListenere - the event that characterizes the change.public void editingCanceled(javax.swing.event.ChangeEvent e)
editingCanceled in interface javax.swing.event.CellEditorListenere - a ChangeEventpublic void editingStopped(javax.swing.event.ChangeEvent e)
editingStopped in interface javax.swing.event.CellEditorListenere - a ChangeEventpublic void setTableHeader(JXTableHeader newHeader)
tableHeader working with this JTable
to newHeader.
It is legal to have a null tableHeader.
newHeader - new tableHeadergetTableHeader()public int getAutoResizeMode()
setAutoResizeMode(int),
Container.doLayout()public void createDefaultColumnsFromModel()
getColumnCount method
defined in the TableModel interface.
Clears any existing columns before creating the new columns based on information from the model.
getAutoCreateColumnsFromModel()
public void setColumnSelectionInterval(int index0,
int index1)
throws java.lang.IllegalArgumentException
index0 to index1,
inclusive.
index0 - one end of the intervalindex1 - the other end of the interval
java.lang.IllegalArgumentException - if index0 or
index1 lie outside
[0, getColumnCount()-1]
public void addColumnSelectionInterval(int index0,
int index1)
throws java.lang.IllegalArgumentException
index0 to index1,
inclusive, to the current selection.
index0 - one end of the intervalindex1 - the other end of the interval
java.lang.IllegalArgumentException - if index0 or
index1 lie outside
[0, getColumnCount()-1]public int getSelectedColumn()
public int[] getSelectedColumns()
getSelectedColumn()public int getSelectedColumnCount()
public boolean isColumnSelected(int column)
throws java.lang.IllegalArgumentException
column - the column in the column model
column is selected, where
0 is the first column
java.lang.IllegalArgumentException - if column is not in the
valid rangepublic int columnAtPoint(java.awt.Point point)
point lies in,
or -1 if the result is not in the range
[0, getColumnCount()-1].
point - the location of interest
point lies in,
or -1 if the result is not in the range
[0, getColumnCount()-1]rowAtPoint(java.awt.Point)
public java.awt.Rectangle getCellRect(int row,
int column,
boolean includeSpacing)
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.
row - the row index where the desired cell
is locatedcolumn - 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 indexincludeSpacing - if false, return the true cell bounds -
computed by subtracting the intercell
spacing from the height and widths of
the column and row models
row,columnpublic javax.swing.plaf.TableUI getUI()
TableUI object that renders this componentpublic void setUI(javax.swing.plaf.TableUI tableUi)
tableUi - the TableUI L&F objectJTable.setUI(javax.swing.plaf.TableUI)
public java.awt.Component prepareEditor(javax.swing.table.TableCellEditor editor,
int row,
int column)
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.
editor - the TableCellEditor to set uprow - the row of the cell to edit,
where 0 is the first rowcolumn - the column of the cell to edit,
where 0 is the first column
Component being editedpublic void addFrozenColumn(javax.swing.table.TableColumn aColumn)
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.
aColumn - the TableColumn to be addedremoveColumn(javax.swing.table.TableColumn)public void removeFrozenColumn(javax.swing.table.TableColumn aColumn)
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.
aColumn - the TableColumn to be removedaddFrozenColumn(javax.swing.table.TableColumn)protected JScrollPaneAdjuster getAdjuster()
public void setTransferHandler(javax.swing.TransferHandler newHandler)
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.
newHandler - mechanism for transfer of data to
and from the componentTransferHandler,
JComponent.setTransferHandler(javax.swing.TransferHandler)public javax.swing.TransferHandler getTransferHandler()
transferHandler property.
transferHandler propertyTransferHandler,
setTransferHandler(javax.swing.TransferHandler)public void addMouseListener(java.awt.event.MouseListener l)
l is null, no
exception is thrown and no action is performed.
l - the mouse listenerMouseEvent,
MouseListener,
removeMouseListener(java.awt.event.MouseListener),
getMouseListeners(),
Component.addMouseListener(java.awt.event.MouseListener)public void removeMouseListener(java.awt.event.MouseListener l)
l is null,
no exception is thrown and no action is performed.
l - the mouse listenerMouseEvent,
MouseListener,
addMouseListener(java.awt.event.MouseListener),
getMouseListeners(),
Component.removeMouseListener(java.awt.event.MouseListener)public java.awt.event.MouseListener[] getMouseListeners()
MouseListeners
or an empty array if no mouse
listeners are currently registeredaddMouseListener(java.awt.event.MouseListener),
removeMouseListener(java.awt.event.MouseListener),
Component.getMouseListeners()public void addMouseMotionListener(java.awt.event.MouseMotionListener l)
l is null,
no exception is thrown and no action is performed.
l - the mouse motion listenerMouseEvent,
MouseMotionListener,
removeMouseMotionListener(java.awt.event.MouseMotionListener),
getMouseMotionListeners(),
Component.addMouseMotionListener(java.awt.event.MouseMotionListener)public void removeMouseMotionListener(java.awt.event.MouseMotionListener l)
l is null,
no exception is thrown and no action is performed.
l - the mouse motion listenerMouseEvent,
MouseMotionListener,
addMouseMotionListener(java.awt.event.MouseMotionListener),
getMouseMotionListeners(),
Component.removeMouseMotionListener(java.awt.event.MouseMotionListener)public java.awt.event.MouseMotionListener[] getMouseMotionListeners()
MouseMotionListeners
or an empty array if no mouse motion
listeners are currently registeredaddMouseMotionListener(java.awt.event.MouseMotionListener),
removeMouseMotionListener(java.awt.event.MouseMotionListener),
Component.getMouseMotionListeners()public void addMouseWheelListener(java.awt.event.MouseWheelListener l)
l - the mouse wheel listener.MouseWheelEvent,
MouseWheelListener,
removeMouseWheelListener(java.awt.event.MouseWheelListener),
getMouseWheelListeners(),
Component.addMouseWheelListener(java.awt.event.MouseWheelListener)public void removeMouseWheelListener(java.awt.event.MouseWheelListener l)
l - the mouse wheel listener.MouseWheelEvent,
MouseWheelListener,
addMouseWheelListener(java.awt.event.MouseWheelListener),
getMouseWheelListeners(),
Component.removeMouseWheelListener(java.awt.event.MouseWheelListener)public java.awt.event.MouseWheelListener[] getMouseWheelListeners()
MouseWheelListeners
or an empty array if no mouse wheel
listeners are currently registeredaddMouseWheelListener(java.awt.event.MouseWheelListener),
removeMouseWheelListener(java.awt.event.MouseWheelListener),
Component.getMouseWheelListeners()public java.util.EventListener[] getListeners(java.lang.Class listenerType)
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.
listenerType - the type of listeners requested; this parameter
should specify an interface that descends from
java.util.EventListener
FooListeners on this component,
or an empty array if no such listeners have been addedgetMouseListeners()public void setBackground(java.awt.Color bg)
JComponent.setBackground(java.awt.Color)public void setOpaque(boolean isOpaque)
JComponent.setOpaque(boolean)public void setScrollPaneUI(javax.swing.plaf.ScrollPaneUI scrollpaneui)
JScrollPane.setUI(javax.swing.plaf.ScrollPaneUI)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||