|
|||||||||
| Home >> All >> javax >> [ swing overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
javax.swing
Class JTable

java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JTable
- All Implemented Interfaces:
- javax.accessibility.Accessible, javax.swing.event.CellEditorListener, java.util.EventListener, java.awt.image.ImageObserver, javax.swing.event.ListSelectionListener, java.awt.MenuContainer, Scrollable, java.io.Serializable, javax.swing.event.TableColumnModelListener, javax.swing.event.TableModelListener
- public class JTable
- extends JComponent
- implements javax.swing.event.TableModelListener, Scrollable, javax.swing.event.TableColumnModelListener, javax.swing.event.ListSelectionListener, javax.swing.event.CellEditorListener, javax.accessibility.Accessible
- extends JComponent
The table component, displaying information, organized in rows and columns. The table can be placed in the scroll bar and have the optional header that is always visible. Cell values may be editable after double clicking on the cell. Cell columns may have various data types, that are displayed and edited by the different renderers and editors. It is possible to set different column width. The columns are also resizeable by dragging the column boundary in the header.
| Nested Class Summary | |
protected class |
JTable.AccessibleJTable
Provides accessibility support for JTable. |
private class |
JTable.BooleanCellRenderer
A cell renderer for boolean values. |
private class |
JTable.DateCellRenderer
A cell renderer for Date values. |
private class |
JTable.DoubleCellRenderer
A cell renderer for Double values. |
private class |
JTable.FloatCellRenderer
A cell renderer for Float values. |
private class |
JTable.IconCellRenderer
A cell renderer for Icon values. |
private class |
JTable.NumberCellRenderer
A cell renderer for Number values. |
(package private) class |
JTable.TableColumnPropertyChangeHandler
Handles property changes from the TableColumns of this
JTable. |
private class |
JTable.TableTextField
The JTable text component (used in editing) always has the table as its parent. |
| Nested classes inherited from class javax.swing.JComponent |
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
When resizing column i in a table of n
columns, automatically change all columns in the range [0,
n) (with the exception of column i) uniformly, to provide or
absorb excess space requirements. |
static int |
AUTO_RESIZE_LAST_COLUMN
When resizing column i in a table of n
columns, automatically change column n-1 (the last column
in the table) to provide or absorb excess space requirements. |
static int |
AUTO_RESIZE_NEXT_COLUMN
When resizing column i, automatically change only the
single column i+1 to provide or absorb excess space
requirements. |
static int |
AUTO_RESIZE_OFF
When resizing columns, do not automatically change any columns. |
static int |
AUTO_RESIZE_SUBSEQUENT_COLUMNS
When resizing column i in a table of n
columns, automatically change all columns in the range [i+1,
n), uniformly, to provide or absorb excess space requirements. |
protected boolean |
autoCreateColumnsFromModel
Whether or not the table should automatically compute a matching javax.swing.table.TableColumnModel and assign it to the columnModel 55
property when the dataModel 55 property is changed. |
protected int |
autoResizeMode
A numeric code specifying the resizing behavior of the table. |
protected javax.swing.table.TableCellEditor |
cellEditor
The current cell editor. |
protected boolean |
cellSelectionEnabled
Obsolete. |
private boolean |
clientRowHeightSet
Indicates if the rowHeight property has been set by a client program or by the UI. |
protected javax.swing.table.TableColumnModel |
columnModel
A model of various aspects of the columns of the table, not including the data stored in them. |
protected javax.swing.table.TableModel |
dataModel
The model for data stored in the table. |
protected java.util.Hashtable |
defaultEditorsByColumnClass
A table mapping java.lang.Class objects to javax.swing.table.TableCellEditor objects. |
protected java.util.Hashtable |
defaultRenderersByColumnClass
A table mapping java.lang.Class objects to javax.swing.table.TableCellEditor objects. |
private boolean |
dragEnabled
Whether or not drag-and-drop is enabled on this table. |
protected int |
editingColumn
The column that is edited, -1 if the table is not edited currently. |
protected int |
editingRow
The row that is edited, -1 if the table is not edited currently. |
protected java.awt.Component |
editorComp
The component that is used for editing. |
protected java.awt.Color |
gridColor
The color to paint the grid lines of the table, when either showHorizontalLines 55 or showVerticalLines 55 is set. |
protected java.awt.Dimension |
preferredViewportSize
The size this table would prefer its viewport assume, if it is contained in a JScrollPane. |
private java.awt.Rectangle |
rectCache
A Rectangle object to be reused in getCellRect(int, int, boolean) 55 . |
protected int |
rowHeight
The height in pixels of any row of the table. |
protected int |
rowMargin
The height in pixels of the gap left between any two rows of the table. |
protected boolean |
rowSelectionAllowed
Whether or not the table should allow row selection. |
private static java.lang.String |
SELECTION_BACKGROUND_CHANGED_PROPERTY
The name carried in property change events when the selectionBackground 55 property changes. |
private static java.lang.String |
SELECTION_FOREGROUND_CHANGED_PROPERTY
The name carried in property change events when the selectionForeground 55 property changes. |
protected java.awt.Color |
selectionBackground
The color to paint the background of selected cells. |
protected java.awt.Color |
selectionForeground
The color to paint the foreground of selected cells. |
protected ListSelectionModel |
selectionModel
A model of the rows of this table which are currently selected. |
private static long |
serialVersionUID
|
protected boolean |
showHorizontalLines
The showHorizontalLines property. |
protected boolean |
showVerticalLines
The showVerticalLines property. |
private boolean |
surrendersFocusOnKeystroke
Whether cell editors should receive keyboard focus when the table is activated. |
(package private) JTable.TableColumnPropertyChangeHandler |
tableColumnPropertyChangeHandler
The property handler for this table's columns. |
protected javax.swing.table.JTableHeader |
tableHeader
The tableHeader property. |
(package private) JTable |
this_table
This table, for referring identically name methods from inner classes. |
| Fields inherited from class javax.swing.JComponent |
accessibleContext, alignmentX, alignmentY, autoscrolls, border, debugGraphicsOptions, doubleBuffered, isCompletelyDirty, isPaintingDoubleBuffered, listenerList, maximumSize, minimumSize, opaque, preferredSize, requestFocusEnabled, TOOL_TIP_TEXT_KEY, toolTipText, 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 | |
JTable()
Creates a new JTable instance. |
|
JTable(int numRows,
int numColumns)
Creates a new JTable instance with the given number
of rows and columns. |
|
JTable(java.lang.Object[][] data,
java.lang.Object[] columnNames)
Creates a new JTable instance, storing the given data
array and heaving the given column names. |
|
JTable(javax.swing.table.TableModel model)
Creates a new JTable instance, using the given data model
object that provides information about the table content. |
|
JTable(javax.swing.table.TableModel dm,
javax.swing.table.TableColumnModel cm)
Creates a new JTable instance, using the given model object
that provides information about the table content. |
|
JTable(javax.swing.table.TableModel dm,
javax.swing.table.TableColumnModel cm,
ListSelectionModel sm)
Creates a new JTable instance, providing data model,
column model and list selection model. |
|
JTable(java.util.Vector data,
java.util.Vector columnNames)
Creates a new JTable instance that uses data and column
names, stored in java.util.Vectors. |
|
| Method Summary | |
void |
addColumn(javax.swing.table.TableColumn column)
Add the new table column. |
void |
addColumnSelectionInterval(int index0,
int index1)
|
void |
addNotify()
Receives notification if this component is added to a parent component. |
void |
addRowSelectionInterval(int index0,
int index1)
|
void |
changeSelection(int rowIndex,
int columnIndex,
boolean toggle,
boolean extend)
|
void |
clearSelection()
|
void |
columnAdded(javax.swing.event.TableColumnModelEvent event)
Invoked when the column is added. |
int |
columnAtPoint(java.awt.Point point)
Returns index of the column that contains specified point or -1 if this table doesn't contain this point. |
void |
columnMarginChanged(javax.swing.event.ChangeEvent event)
Invoked when the column margin is changed. |
void |
columnMoved(javax.swing.event.TableColumnModelEvent event)
Invoked when the column is moved. |
void |
columnRemoved(javax.swing.event.TableColumnModelEvent event)
Invoked when the column is removed. |
void |
columnSelectionChanged(javax.swing.event.ListSelectionEvent event)
Invoked when the the column selection changes, repaints the changed columns. |
protected void |
configureEnclosingScrollPane()
|
int |
convertColumnIndexToModel(int vc)
Convert the table model index into the table column number. |
int |
convertColumnIndexToView(int mc)
Convert the table column number to the table column model index. |
private static int |
countSelections(ListSelectionModel lsm)
|
protected javax.swing.table.TableColumnModel |
createDefaultColumnModel()
Create the default table column model that is used if the user-defined column model is not provided. |
void |
createDefaultColumnsFromModel()
Clears any existing columns from the JTable's
javax.swing.table.TableColumnModel and creates new columns to match the values in
the data (javax.swing.table.TableModel) used by the table. |
protected javax.swing.table.TableModel |
createDefaultDataModel()
Create the default table data model that is used if the user-defined data model is not provided. |
protected void |
createDefaultEditors()
Create the default editors for this table. |
protected void |
createDefaultRenderers()
Create the default renderers for this table. |
protected ListSelectionModel |
createDefaultSelectionModel()
Create the default table selection model that is used if the user-defined selection model is not provided. |
protected javax.swing.table.JTableHeader |
createDefaultTableHeader()
Create the default table header, if the user - defined table header is not provided. |
static JScrollPane |
createScrollPaneForTable(JTable table)
Deprecated. 1.0.2, replaced by new JScrollPane(JTable) |
private void |
distributeSpill(javax.swing.table.TableColumn[] cols,
int spill)
This distributes the superfluous width in a table evenly on its columns. |
private void |
distributeSpillResizing(javax.swing.table.TableColumn[] cols,
int spill,
javax.swing.table.TableColumn resizeIt)
This distributes the superfluous width in a table, setting the width of the column being resized strictly to its preferred width. |
void |
doLayout()
Set the widths of all columns, taking they preferred widths into consideration. |
boolean |
editCellAt(int row,
int column)
Programmatically starts editing the specified cell. |
boolean |
editCellAt(int row,
int column,
java.util.EventObject e)
Programmatically starts editing the specified cell. |
void |
editingCanceled(javax.swing.event.ChangeEvent event)
Invoked when the editing is cancelled. |
void |
editingStopped(javax.swing.event.ChangeEvent event)
Finish the current editing session and update the table with the new value by calling setValueAt(java.lang.Object, int, int) 55 . |
javax.accessibility.AccessibleContext |
getAccessibleContext()
Get the value of the JComponent.accessibleContext 55 property. |
boolean |
getAutoCreateColumnsFromModel()
Get the value of the autoCreateColumnsFromModel 55 property. |
int |
getAutoResizeMode()
Get the value of the autoResizeMode 55 property. |
javax.swing.table.TableCellEditor |
getCellEditor()
Get the value of the cellEditor 55 property. |
javax.swing.table.TableCellEditor |
getCellEditor(int row,
int column)
Get the cell editor, suitable for editing the given cell. |
java.awt.Rectangle |
getCellRect(int row,
int column,
boolean includeSpacing)
Calculate the visible rectangle for a particular row and column. |
javax.swing.table.TableCellRenderer |
getCellRenderer(int row,
int column)
Get the cell renderer for rendering the given cell. |
boolean |
getCellSelectionEnabled()
Get the value of the cellSelectionEnabled 55 property. |
javax.swing.table.TableColumn |
getColumn(java.lang.Object identifier)
Get table column with the given identified. |
java.lang.Class |
getColumnClass(int column)
Get the class (datatype) of the column. |
int |
getColumnCount()
Get the value of the columnCount property by
delegation to the columnModel 55 field. |
javax.swing.table.TableColumnModel |
getColumnModel()
Get the value of the columnModel 55 property. |
java.lang.String |
getColumnName(int column)
Get the name of the column. |
boolean |
getColumnSelectionAllowed()
Get the value of the columnSelectionAllowed property. |
javax.swing.table.TableCellEditor |
getDefaultEditor(java.lang.Class columnClass)
Get the default editor for editing values of the given type (String, Boolean and so on). |
javax.swing.table.TableCellRenderer |
getDefaultRenderer(java.lang.Class columnClass)
Get the default renderer for rendering the given data type. |
boolean |
getDragEnabled()
Get the value of the dragEnabled 55 property. |
int |
getEditingColumn()
Get the column, currently being edited |
int |
getEditingRow()
Get the row currently being edited. |
java.awt.Component |
getEditorComponent()
Get the editor component that is currently editing one of the cells |
java.awt.Color |
getGridColor()
Get the value of the gridColor 55 property. |
java.awt.Dimension |
getIntercellSpacing()
Get the value of the intercellSpacing property. |
javax.swing.table.TableModel |
getModel()
Get the value of the dataModel 55 property. |
java.awt.Dimension |
getPreferredScrollableViewportSize()
Get the value of the preferredViewportSize 55 property. |
int |
getRowCount()
Get the value of the rowCount property by
delegation to the dataModel 55 field. |
int |
getRowHeight()
Get the value of the rowHeight 55 property. |
int |
getRowHeight(int row)
Get the height of the specified row. |
int |
getRowMargin()
Get the value of the rowMargin 55 property. |
boolean |
getRowSelectionAllowed()
Get the value of the rowSelectionAllowed 55 property. |
int |
getScrollableBlockIncrement(java.awt.Rectangle visibleRect,
int orientation,
int direction)
Return the preferred scrolling amount (in pixels) for the given scrolling direction and orientation when scrolling in large amounts (pages). |
boolean |
getScrollableTracksViewportHeight()
Get the value of the scrollableTracksViewportHeight property. |
boolean |
getScrollableTracksViewportWidth()
Get the value of the scrollableTracksViewportWidth property. |
int |
getScrollableUnitIncrement(java.awt.Rectangle visibleRect,
int orientation,
int direction)
Return the preferred scrolling amount (in pixels) for the given scrolling direction and orientation. |
int |
getSelectedColumn()
Get the value of the selectedColumn property by
delegation to the columnModel 55 field. |
int |
getSelectedColumnCount()
Get the value of the selectedColumnCount property by
delegation to the columnModel 55 field. |
int[] |
getSelectedColumns()
Get the value of the selectedColumns property by
delegation to the columnModel 55 field. |
int |
getSelectedRow()
Get the value of the selectedRow property by delegation to the ListSelectionModel.getMinSelectionIndex() 55 method of the
selectionModel 55 field. |
int |
getSelectedRowCount()
Get the value of the selectedRowCount property by
delegation to the selectionModel 55 field. |
int[] |
getSelectedRows()
Get the value of the selectedRows property by
delegation to the selectionModel 55 field. |
java.awt.Color |
getSelectionBackground()
Get the value of the selectionBackground 55 property. |
java.awt.Color |
getSelectionForeground()
Get the value of the selectionForeground 55 property. |
ListSelectionModel |
getSelectionModel()
Get the value of the selectionModel 55 property. |
private static int[] |
getSelections(ListSelectionModel lsm)
|
boolean |
getShowHorizontalLines()
Get the value of the showHorizontalLines 55 property. |
boolean |
getShowVerticalLines()
Get the value of the showVerticalLines 55 property. |
boolean |
getSurrendersFocusOnKeystroke()
Returns whether cell editors of this table should receive keyboard focus when the editor is activated by a keystroke. |
javax.swing.table.JTableHeader |
getTableHeader()
Get the value of the tableHeader 55 property. |
javax.swing.plaf.TableUI |
getUI()
This method returns the table's UI delegate. |
java.lang.String |
getUIClassID()
Get the value of the UIClassID property. |
java.lang.Object |
getValueAt(int row,
int column)
Get the cell value at the given position. |
protected void |
initializeLocalVars()
Initialize local variables to default values. |
boolean |
isCellEditable(int row,
int column)
Returns true if the specified cell is editable, and
false otherwise. |
boolean |
isCellSelected(int row,
int column)
Checks if the given cell is selected. |
boolean |
isColumnSelected(int column)
Checks if the given column is selected. |
boolean |
isEditing()
Check if one of the table cells is currently being edited. |
boolean |
isRowSelected(int row)
Checks if the given row is selected. |
void |
moveColumn(int column,
int targetColumn)
Moves column at the specified index to new given location. |
private void |
moveToCellBeingEdited(java.awt.Component component)
Move the given component under the cell being edited. |
java.awt.Component |
prepareEditor(javax.swing.table.TableCellEditor editor,
int row,
int column)
Prepares the editor by querying 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)
Prepare the renderer for rendering the given cell. |
void |
removeColumn(javax.swing.table.TableColumn column)
Removes specified column from displayable columns of this table. |
void |
removeColumnSelectionInterval(int index0,
int index1)
|
void |
removeEditor()
Discards the editor object. |
void |
removeNotify()
Receives notification that this component no longer has a parent. |
void |
removeRowSelectionInterval(int index0,
int index1)
|
protected void |
resizeAndRepaint()
This revalidates the JTable and queues a repaint. |
int |
rowAtPoint(java.awt.Point point)
Returns index of the row that contains specified point or -1 if this table doesn't contain this point. |
void |
selectAll()
Select all table. |
void |
setAutoCreateColumnsFromModel(boolean autoCreate)
Set the value of the autoCreateColumnsFromModel 55 flag. |
void |
setAutoResizeMode(int a)
Set the value of the autoResizeMode 55 property. |
void |
setCellEditor(javax.swing.table.TableCellEditor c)
Set the value of the cellEditor 55 property. |
void |
setCellSelectionEnabled(boolean c)
Set the value of the cellSelectionEnabled 55 property. |
void |
setColumnModel(javax.swing.table.TableColumnModel c)
Set the value of the columnModel 55 property. |
void |
setColumnSelectionAllowed(boolean c)
Set the value of the columnSelectionAllowed property. |
void |
setColumnSelectionInterval(int index0,
int index1)
|
void |
setDefaultEditor(java.lang.Class columnClass,
javax.swing.table.TableCellEditor editor)
Set the default editor for the given column class (column data type). |
void |
setDefaultRenderer(java.lang.Class columnClass,
javax.swing.table.TableCellRenderer rend)
Set default renderer for rendering the given data type. |
void |
setDragEnabled(boolean d)
Set the value of the dragEnabled 55 property. |
void |
setEditingColumn(int column)
Set the column, currently being edited |
void |
setEditingRow(int row)
Set the row currently being edited. |
void |
setGridColor(java.awt.Color g)
Set the value of the gridColor 55 property. |
void |
setIntercellSpacing(java.awt.Dimension i)
Set the value of the intercellSpacing property. |
void |
setModel(javax.swing.table.TableModel m)
Set the value of the dataModel 55 property. |
void |
setPreferredScrollableViewportSize(java.awt.Dimension p)
Set the value of the preferredViewportSize 55 property. |
void |
setRowHeight(int r)
Set the value of the rowHeight 55 property. |
void |
setRowHeight(int row,
int rh)
Sets the value of the rowHeight property for the specified row. |
void |
setRowMargin(int r)
Set the value of the rowMargin 55 property. |
void |
setRowSelectionAllowed(boolean r)
Set the value of the rowSelectionAllowed 55 property. |
void |
setRowSelectionInterval(int index0,
int index1)
|
void |
setSelectionBackground(java.awt.Color s)
Set the value of the selectionBackground 55 property. |
void |
setSelectionForeground(java.awt.Color s)
Set the value of the selectionForeground 55 property. |
void |
setSelectionMode(int s)
Set the value of the selectionMode property by
delegation to the selectionModel 55 field. |
void |
setSelectionModel(ListSelectionModel s)
Set the value of the selectionModel 55 property. |
void |
setShowGrid(boolean s)
Set the value of the showGrid property. |
void |
setShowHorizontalLines(boolean s)
Set the value of the showHorizontalLines 55 property. |
void |
setShowVerticalLines(boolean s)
Set the value of the showVerticalLines 55 property. |
void |
setSurrendersFocusOnKeystroke(boolean value)
Sets whether cell editors of this table should receive keyboard focus when the editor is activated by a keystroke. |
void |
setTableHeader(javax.swing.table.JTableHeader t)
Set the value of the tableHeader 55 property. |
void |
setUI(javax.swing.plaf.TableUI ui)
This method sets the table's UI delegate. |
(package private) void |
setUIProperty(java.lang.String propertyName,
java.lang.Object value)
Helper method for LookAndFeel.installProperty(JComponent, String, Object) 55 . |
void |
setValueAt(java.lang.Object value,
int row,
int column)
Set value for the cell at the given position. |
void |
sizeColumnsToFit(boolean lastColumnOnly)
Deprecated. Replaced by doLayout() |
void |
sizeColumnsToFit(int resizingColumn)
Obsolete since JDK 1.4. |
void |
tableChanged(javax.swing.event.TableModelEvent event)
Invoked when the table changes. |
protected void |
unconfigureEnclosingScrollPane()
|
void |
updateUI()
This method should be overridden in subclasses. |
void |
valueChanged(javax.swing.event.ListSelectionEvent event)
Invoked when another table row is selected. |
JAVADOC