GNU Classpath (0.20) | |
Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
public class JTable
extends JComponent
Nested Class Summary | |
protected class |
|
Nested classes/interfaces inherited from class javax.swing.JComponent | |
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container | |
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component | |
Component.AccessibleAWTComponent , Component.BltBufferStrategy , Component.FlipBufferStrategy |
Field Summary | |
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
protected boolean |
|
protected int |
|
protected TableCellEditor |
|
protected boolean |
|
protected TableColumnModel |
|
protected TableModel |
|
protected Hashtable |
|
protected Hashtable |
|
protected int |
|
protected int |
|
protected Component |
|
protected Color |
|
protected Dimension |
|
protected int |
|
protected int |
|
protected boolean |
|
protected Color |
|
protected Color |
|
protected ListSelectionModel |
|
protected boolean |
|
protected boolean |
|
protected JTableHeader |
|
Fields inherited from class javax.swing.JComponent | |
TOOL_TIP_TEXT_KEY , UNDEFINED_CONDITION , WHEN_ANCESTOR_OF_FOCUSED_COMPONENT , WHEN_FOCUSED , WHEN_IN_FOCUSED_WINDOW , accessibleContext , listenerList , ui |
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 | |
| |
| |
| |
| |
|
Method Summary | |
void |
|
void |
|
void |
|
void |
|
void |
|
void | |
void |
|
int |
|
void |
|
void |
|
void | |
void | |
protected void | |
int |
|
int |
|
protected TableColumnModel | |
void |
|
protected TableModel | |
protected void | |
protected void | |
protected ListSelectionModel | |
protected JTableHeader | |
static JScrollPane |
|
void |
|
boolean |
|
boolean |
|
void |
|
void |
|
AccessibleContext |
|
boolean |
|
int |
|
TableCellEditor |
|
TableCellEditor |
|
Rectangle |
|
TableCellRenderer |
|
boolean |
|
TableColumn | |
Class |
|
int |
|
TableColumnModel |
|
String |
|
boolean |
|
TableCellEditor |
|
TableCellRenderer |
|
boolean |
|
int | |
int | |
Component | |
Color |
|
Dimension |
|
TableModel | |
Dimension |
|
int |
|
int |
|
int |
|
int |
|
boolean |
|
int |
|
boolean |
|
boolean |
|
int |
|
int |
|
int |
|
int[] |
|
int |
|
int |
|
int[] |
|
Color |
|
Color |
|
ListSelectionModel |
|
boolean |
|
boolean |
|
boolean |
|
JTableHeader |
|
TableUI |
|
String | |
Object |
|
protected void | |
boolean |
|
boolean |
|
boolean |
|
boolean | |
boolean |
|
void |
|
Component |
|
Component |
|
void |
|
void |
|
void |
|
void |
|
void |
|
protected void |
|
int |
|
void | |
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void | |
void |
|
void |
|
void |
|
void |
|
protected void | |
void |
|
void |
|
Methods inherited from class java.lang.Object | |
clone , equals , finalize , getClass , hashCode , notify , notifyAll , toString , wait , wait , wait |
public static final int AUTO_RESIZE_ALL_COLUMNS
When resizing columni
in a table ofn
columns, automatically change all columns in the range[0, n)
(with the exception of column i) uniformly, to provide or absorb excess space requirements.
- Field Value:
- 4
public static final int AUTO_RESIZE_LAST_COLUMN
When resizing columni
in a table ofn
columns, automatically change columnn-1
(the last column in the table) to provide or absorb excess space requirements.
- Field Value:
- 3
public static final int AUTO_RESIZE_NEXT_COLUMN
When resizing columni
, automatically change only the single columni+1
to provide or absorb excess space requirements.
- Field Value:
- 1
public static final int AUTO_RESIZE_OFF
When resizing columns, do not automatically change any columns. In this case the table should be enclosed in aJScrollPane
in order to accomodate cases in which the table size exceeds its visible area.
- Field Value:
- 0
public static final int AUTO_RESIZE_SUBSEQUENT_COLUMNS
When resizing columni
in a table ofn
columns, automatically change all columns in the range[i+1, n)
, uniformly, to provide or absorb excess space requirements.
- Field Value:
- 2
protected boolean autoCreateColumnsFromModel
Whether or not the table should automatically compute a matchingTableColumnModel
and assign it to thecolumnModel
property when thedataModel
property is changed.
protected int autoResizeMode
A numeric code specifying the resizing behavior of the table. Must be one ofAUTO_RESIZE_ALL_COLUMNS
(the default),AUTO_RESIZE_LAST_COLUMN
,AUTO_RESIZE_NEXT_COLUMN
,AUTO_RESIZE_SUBSEQUENT_COLUMNS
, orAUTO_RESIZE_OFF
.
- See Also:
doLayout()
,setAutoResizeMode(int)
,getAutoResizeMode()
protected boolean cellSelectionEnabled
Deprecated. Use
rowSelectionAllowed
,getColumnSelectionAllowed()
, or the combined methodsgetCellSelectionEnabled()
andsetCellSelectionEnabled(boolean)
.
protected TableColumnModel columnModel
A model of various aspects of the columns of the table, not including the data stored in them. TheTableColumnModel
is principally concerned with holding a set ofTableColumn
objects, each of which describes the display parameters of a column and the numeric index of the column from the data model which the column is presenting. The TableColumnModel also contains aListSelectionModel
which indicates which columns are currently selected. This selection model works in combination with theselectionModel
of the table itself to specify a table selection: a combination of row and column selections. Most application programmers do not need to work with this property at all: settingautoCreateColumnsFromModel
will construct the columnModel automatically, and the table acts as a facade for most of the interesting properties of the columnModel anyways.
protected TableModel dataModel
The model for data stored in the table. Confusingly, the published API requires that this field be calleddataModel
, despite its property name. The table listens to its model as aTableModelListener
.
protected Hashtable defaultEditorsByColumnClass
A table mappingClass
objects toTableCellEditor
objects. This table is consulted by the FIXME
protected Hashtable defaultRenderersByColumnClass
A table mappingClass
objects toTableCellEditor
objects. This table is consulted by the FIXME
protected int editingColumn
The column that is edited, -1 if the table is not edited currently.
protected Component editorComp
The component that is used for editing.null
if the table is not editing currently.
protected Color gridColor
The color to paint the grid lines of the table, when eithershowHorizontalLines
orshowVerticalLines
is set.
- See Also:
setGridColor(Color)
,getGridColor()
protected Dimension preferredViewportSize
The size this table would prefer its viewport assume, if it is contained in aJScrollPane
.
protected int rowHeight
The height in pixels of any row of the table. All rows in a table are of uniform height. This differs from column width, which varies on a per-column basis, and is stored in the individual columns of thecolumnModel
.
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. If the table allows both row and column selection, it is said to allow "cell selection". Previous versions of the JDK supported cell selection as an independent concept, but it is now represented solely in terms of simultaneous row and column selection.
protected Color selectionBackground
The color to paint the background of selected cells. Fires a property change event with nameSELECTION_BACKGROUND_CHANGED_PROPERTY
when its value changes.
protected Color selectionForeground
The color to paint the foreground of selected cells. Fires a property change event with nameSELECTION_FOREGROUND_CHANGED_PROPERTY
when its value changes.
protected ListSelectionModel selectionModel
A model of the rows of this table which are currently selected. This model is used in combination with the column selection model held as a member of thecolumnModel
property, to represent the rows and columns (or both: cells) of the table which are currently selected.
public JTable(int numRows, int numColumns)
Creates a newJTable
instance.
- Parameters:
numRows
- anint
valuenumColumns
- anint
value
public JTable(Object[][] data, Object[] columnNames)
Creates a newJTable
instance.
- Parameters:
data
- anObject[][]
valuecolumnNames
- anObject[]
value
public JTable(Vector data, Vector columnNames)
Creates a newJTable
instance.
- Parameters:
data
- aVector
valuecolumnNames
- aVector
value
public JTable(TableModel dm)
Creates a newJTable
instance.
- Parameters:
dm
- aTableModel
value
public JTable(TableModel dm, TableColumnModel cm)
Creates a newJTable
instance.
- Parameters:
dm
- aTableModel
valuecm
- aTableColumnModel
value
public JTable(TableModel dm, TableColumnModel cm, ListSelectionModel sm)
Creates a newJTable
instance.
- Parameters:
dm
- aTableModel
valuecm
- aTableColumnModel
valuesm
- aListSelectionModel
value
public void addNotify()
Called when this container is added to another container to inform it to create its peer. Peers for any child components will also be created.
- Overrides:
- addNotify in interface JComponent
public void changeSelection(int rowIndex, int columnIndex, boolean toggle, boolean extend)
public void columnAdded(TableColumnModelEvent event)
- Specified by:
- columnAdded in interface TableColumnModelListener
public int columnAtPoint(Point point)
Returns index of the column that contains specified point or -1 if this table doesn't contain this point.
- Parameters:
point
- point to identify the column
- Returns:
- index of the column that contains specified point or -1 if this table doesn't contain this point.
public void columnMarginChanged(ChangeEvent event)
- Specified by:
- columnMarginChanged in interface TableColumnModelListener
public void columnMoved(TableColumnModelEvent event)
- Specified by:
- columnMoved in interface TableColumnModelListener
public void columnRemoved(TableColumnModelEvent event)
- Specified by:
- columnRemoved in interface TableColumnModelListener
public void columnSelectionChanged(ListSelectionEvent event)
- Specified by:
- columnSelectionChanged in interface TableColumnModelListener
public void createDefaultColumnsFromModel()
Clears any existing columns from theJTable
'sTableColumnModel
and creates new columns to match the values in the data (TableModel
) used by the table.
public static JScrollPane createScrollPaneForTable(JTable table)
Deprecated. 1.0.2, replaced by
new JScrollPane(JTable)
public boolean editCellAt(int row, int column)
Programmatically starts editing the specified cell.
- Parameters:
row
- the row of the cell to edit.column
- the column of the cell to edit.
public boolean editCellAt(int row, int column, EventObject e)
Programmatically starts editing the specified cell.
- Parameters:
row
- the row of the cell to edit.column
- the column of the cell to edit.
public void editingCanceled(ChangeEvent event)
- Specified by:
- editingCanceled in interface CellEditorListener
public void editingStopped(ChangeEvent event)
- Specified by:
- editingStopped in interface CellEditorListener
public AccessibleContext getAccessibleContext()
Get the value of theJComponent.accessibleContext
property.
- Specified by:
- getAccessibleContext in interface Accessible
- Overrides:
- getAccessibleContext in interface JComponent
- Returns:
- The current value of the property
public boolean getAutoCreateColumnsFromModel()
Get the value of theautoCreateColumnsFromModel
property.
- Returns:
- The current value of the property
public int getAutoResizeMode()
Get the value of theautoResizeMode
property.
- Returns:
- The current value of the property
public TableCellEditor getCellEditor()
Get the value of thecellEditor
property.
- Returns:
- The current value of the property
public Rectangle getCellRect(int row, int column, boolean includeSpacing)
Calculate the visible rectangle for a particular row and column. The row and column are specified in visual terms; the column may not match thedataModel
column.
- Parameters:
row
- the visible row to get the cell rectangle ofcolumn
- the visible column to get the cell rectangle of, which may differ from thedataModel
columnincludeSpacing
- whether or not to include the cell margins in the resulting cell. Iffalse
, the result will only contain the inner area of the target cell, not including its margins.
- Returns:
- a rectangle enclosing the specified cell
public boolean getCellSelectionEnabled()
Get the value of thecellSelectionEnabled
property.
- Returns:
- The current value of the property
public int getColumnCount()
Get the value of thecolumnCount
property by delegation to the @{link #columnModel} field.
- Returns:
- The current value of the columnCount property
public TableColumnModel getColumnModel()
Get the value of thecolumnModel
property.
- Returns:
- The current value of the property
public boolean getColumnSelectionAllowed()
Get the value of thecolumnSelectionAllowed
property.
- Returns:
- The current value of the columnSelectionAllowed property
public boolean getDragEnabled()
Get the value of thedragEnabled
property.
- Returns:
- The current value of the property
public Color getGridColor()
Get the value of thegridColor
property.
- Returns:
- The current value of the property
public Dimension getIntercellSpacing()
Get the value of theintercellSpacing
property.
- Returns:
- The current value of the property
public TableModel getModel()
Get the value of thedataModel
property.
- Returns:
- The current value of the property
public Dimension getPreferredScrollableViewportSize()
Get the value of thepreferredViewportSize
property.
- Specified by:
- getPreferredScrollableViewportSize in interface Scrollable
- Returns:
- The current value of the property
public int getRowCount()
Get the value of therowCount
property by delegation to the @{link #dataModel} field.
- Returns:
- The current value of the rowCount property
public int getRowHeight()
Get the value of therowHeight
property.
- Returns:
- The current value of the property
public int getRowHeight(int row)
Get the height of the specified row.
- Parameters:
row
- the row whose height to return
public int getRowMargin()
Get the value of therowMargin
property.
- Returns:
- The current value of the property
public boolean getRowSelectionAllowed()
Get the value of therowSelectionAllowed
property.
- Returns:
- The current value of the property
public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction)
- Specified by:
- getScrollableBlockIncrement in interface Scrollable
public boolean getScrollableTracksViewportHeight()
Get the value of thescrollableTracksViewportHeight
property.
- Specified by:
- getScrollableTracksViewportHeight in interface Scrollable
- Returns:
- The constant value
false
public boolean getScrollableTracksViewportWidth()
Get the value of thescrollableTracksViewportWidth
property.
- Specified by:
- getScrollableTracksViewportWidth in interface Scrollable
- Returns:
true
unless theautoResizeMode
property isAUTO_RESIZE_OFF
public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction)
- Specified by:
- getScrollableUnitIncrement in interface Scrollable
public int getSelectedColumn()
Get the value of theselectedColumn
property by delegation to the @{link #columnModel} field.
- Returns:
- The current value of the selectedColumn property
public int getSelectedColumnCount()
Get the value of theselectedColumnCount
property by delegation to the @{link #columnModel} field.
- Returns:
- The current value of the selectedColumnCount property
public int[] getSelectedColumns()
Get the value of theselectedColumns
property by delegation to the @{link #columnModel} field.
- Returns:
- The current value of the selectedColumns property
public int getSelectedRow()
Get the value of the selectedRow property by delegation to theListSelectionModel.getMinSelectionIndex()
method of theselectionModel
field.
- Returns:
- The current value of the selectedRow property
public int getSelectedRowCount()
Get the value of theselectedRowCount
property by delegation to the @{link #selectionModel} field.
- Returns:
- The current value of the selectedRowCount property
public int[] getSelectedRows()
Get the value of theselectedRows
property by delegation to the @{link #selectionModel} field.
- Returns:
- The current value of the selectedRows property
public Color getSelectionBackground()
Get the value of theselectionBackground
property.
- Returns:
- The current value of the property
public Color getSelectionForeground()
Get the value of theselectionForeground
property.
- Returns:
- The current value of the property
public ListSelectionModel getSelectionModel()
Get the value of theselectionModel
property.
- Returns:
- The current value of the property
public boolean getShowHorizontalLines()
Get the value of theshowHorizontalLines
property.
- Returns:
- The current value of the property
public boolean getShowVerticalLines()
Get the value of theshowVerticalLines
property.
- Returns:
- The current value of the property
public boolean getSurrendersFocusOnKeystroke()
Returns whether cell editors of this table should receive keyboard focus when the editor is activated by a keystroke. The default setting isfalse
which means that the table should keep the keyboard focus until the cell is selected by a mouse click.
- Returns:
- whether cell editors of this table should receive keyboard focus when the editor is activated by a keystroke
- Since:
- 1.4
public JTableHeader getTableHeader()
Get the value of thetableHeader
property.
- Returns:
- The current value of the property
public TableUI getUI()
This method returns the table's UI delegate.
- Returns:
- The table's UI delegate.
public boolean isCellEditable(int row, int column)
Returnstrue
if the specified cell is editable, andfalse
otherwise.
- Parameters:
row
- the row index.column
- the column index.
- Returns:
- A boolean.
public void moveColumn(int column, int targetColumn)
Moves column at the specified index to new given location.
- Parameters:
column
- index of the column to movetargetColumn
- index specifying new location of the column
public Component prepareEditor(TableCellEditor editor, int row, int column)
Prepares the editor by querying for the value and selection state of the cell at (row, column).
- Parameters:
editor
- the TableCellEditor to set uprow
- the row of the cell to editcolumn
- the column of the cell to edit
- Returns:
- the Component being edited
public void removeColumn(TableColumn column)
Removes specified column from displayable columns of this table.
- Parameters:
column
- column to removed
public void removeNotify()
Called when this container is removed from its parent container to inform it to destroy its peer. This causes the peers of all child component to be destroyed as well.
- Overrides:
- removeNotify in interface JComponent
public int rowAtPoint(Point point)
Returns index of the row that contains specified point or -1 if this table doesn't contain this point.
- Parameters:
point
- point to identify the row
- Returns:
- index of the row that contains specified point or -1 if this table doesn't contain this point.
public void setAutoCreateColumnsFromModel(boolean autoCreate)
Set the value of theautoCreateColumnsFromModel
flag. If the flag changes fromfalse
totrue
, thecreateDefaultColumnsFromModel()
method is called.
- Parameters:
autoCreate
- the new value of the flag.
public void setAutoResizeMode(int a)
Set the value of theautoResizeMode
property.
- Parameters:
a
- The new value of the autoResizeMode property
public void setCellEditor(TableCellEditor c)
Set the value of thecellEditor
property. Unregisterthis
as aCellEditorListener
from previouscellEditor
and register it with new parameterc
.
- Parameters:
c
- The new value of the cellEditor property
public void setCellSelectionEnabled(boolean c)
Set the value of thecellSelectionEnabled
property.
- Parameters:
c
- The new value of the cellSelectionEnabled property
public void setColumnModel(TableColumnModel c)
Set the value of thecolumnModel
property. Unregisterthis
as aTableColumnModelListener
from previouscolumnModel
and register it with new parameterc
.
- Parameters:
c
- The new value of the columnModel property
public void setColumnSelectionAllowed(boolean c)
Set the value of thecolumnSelectionAllowed
property.
- Parameters:
c
- The new value of the property
public void setDragEnabled(boolean d)
Set the value of thedragEnabled
property.
- Parameters:
d
- The new value of the dragEnabled property
public void setGridColor(Color g)
Set the value of thegridColor
property.
- Parameters:
g
- The new value of the gridColor property
public void setIntercellSpacing(Dimension i)
Set the value of theintercellSpacing
property.
- Parameters:
i
- The new value of the intercellSpacing property
public void setModel(TableModel m)
Set the value of thedataModel
property. Unregisterthis
as aTableModelListener
from previousdataModel
and register it with new parameterm
.
- Parameters:
m
- The new value of the model property
public void setPreferredScrollableViewportSize(Dimension p)
Set the value of thepreferredViewportSize
property.
- Parameters:
p
- The new value of the preferredViewportSize property
public void setRowHeight(int r)
Set the value of therowHeight
property.
- Parameters:
r
- The new value of the rowHeight property
public void setRowHeight(int row, int rh)
Sets the value of the rowHeight property for the specified row.
- Parameters:
row
- is the row to change the rowHeight ofrh
- is the new rowHeight
public void setRowMargin(int r)
Set the value of therowMargin
property.
- Parameters:
r
- The new value of the rowMargin property
public void setRowSelectionAllowed(boolean r)
Set the value of therowSelectionAllowed
property.
- Parameters:
r
- The new value of the rowSelectionAllowed property
public void setSelectionBackground(Color s)
Set the value of theselectionBackground
property. Fire a PropertyChangeEvent with nameSELECTION_BACKGROUND_CHANGED_PROPERTY
to registered listeners, if selectionBackground changed.
- Parameters:
s
- The new value of the selectionBackground property
public void setSelectionForeground(Color s)
Set the value of theselectionForeground
property. Fire a PropertyChangeEvent with nameSELECTION_FOREGROUND_CHANGED_PROPERTY
to registered listeners, if selectionForeground changed.
- Parameters:
s
- The new value of the selectionForeground property
public void setSelectionMode(int s)
Set the value of theselectionMode
property by delegation to theselectionModel
field. The same selection mode is set for row and column selection models.
- Parameters:
s
- The new value of the property
public void setSelectionModel(ListSelectionModel s)
Set the value of theselectionModel
property. Unregisterthis
as aListSelectionListener
from previousselectionModel
and register it with new parameters
.
- Parameters:
s
- The new value of the selectionModel property
public void setShowGrid(boolean s)
Set the value of theshowGrid
property.
- Parameters:
s
- The new value of the showGrid property
public void setShowHorizontalLines(boolean s)
Set the value of theshowHorizontalLines
property.
- Parameters:
s
- The new value of the showHorizontalLines property
public void setShowVerticalLines(boolean s)
Set the value of theshowVerticalLines
property.
- Parameters:
s
- The new value of the showVerticalLines property
public void setSurrendersFocusOnKeystroke(boolean value)
Sets whether cell editors of this table should receive keyboard focus when the editor is activated by a keystroke. The default setting isfalse
which means that the table should keep the keyboard focus until the cell is selected by a mouse click.
- Parameters:
value
- the value to set
- Since:
- 1.4
public void setTableHeader(JTableHeader t)
Set the value of thetableHeader
property.
- Parameters:
t
- The new value of the tableHeader property
public void setUI(TableUI ui)
This method sets the table's UI delegate.
- Parameters:
ui
- The table's UI delegate.
public void sizeColumnsToFit(boolean lastColumnOnly)
Deprecated. Replaced by
doLayout()
public void sizeColumnsToFit(int resizingColumn)
Obsolete since JDK 1.4. Please usedoLayout()
.
public void tableChanged(TableModelEvent event)
- Specified by:
- tableChanged in interface TableModelListener
public void valueChanged(ListSelectionEvent event)
- Specified by:
- valueChanged in interface ListSelectionListener
GNU Classpath (0.20) |