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<K,V> |
|
protected Hashtable<K,V> |
|
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 , extends Object> getClass , finalize , 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
Obsolete. UserowSelectionAllowed
,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<K,V> defaultEditorsByColumnClass
A table mappingClass
objects toTableCellEditor
objects. This table is consulted by the FIXME
protected Hashtable<K,V> 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 with the given number of rows and columns.
- Parameters:
numRows
- anint
valuenumColumns
- anint
value
public JTable(Object[][] data, Object[] columnNames)
Creates a newJTable
instance, storing the given data array and heaving the given column names. To see the column names, you must place the JTable into theJScrollPane
.
- Parameters:
data
- anObject[][]
the table datacolumnNames
- anObject[]
the column headers
public JTable(Vector<T> data, Vector<T> columnNames)
Creates a newJTable
instance that uses data and column names, stored inVector
s.
- Parameters:
data
- the table datacolumnNames
- the table column names.
public JTable(TableModel model)
Creates a newJTable
instance, using the given data model object that provides information about the table content. The table model object is asked for the table size, other features and also receives notifications in the case when the table has been edited by the user.
- Parameters:
model
- the table model.
public JTable(TableModel dm, TableColumnModel cm)
Creates a newJTable
instance, using the given model object that provides information about the table content. The table data model object is asked for the table size, other features and also receives notifications in the case when the table has been edited by the user. The table column model provides more detailed control on the table column related features.
- Parameters:
dm
- the table data modecm
- the table column model
public JTable(TableModel dm, TableColumnModel cm, ListSelectionModel sm)
Creates a newJTable
instance, providing data model, column model and list selection model. The list selection model manages the selections.
- Parameters:
dm
- data model (manages table data)cm
- column model (manages table columns)sm
- list selection model (manages table selections)
public void addColumn(TableColumn column)
Add the new table column. The table column class allows to specify column features more precisely, setting the preferred width, column data type (column class) and table headers. There is no need the add columns to the table if the default column handling is sufficient.
- Parameters:
column
- the new column to add.
public void addNotify()
Called when the parent of this Component is made visible or when the Component is added to an already visible Container and needs to be shown. A native peer - if any - is created at this time. This method is called automatically by the AWT system and should not be called by user level code.
- Overrides:
- addNotify in interface JComponent
public void changeSelection(int rowIndex, int columnIndex, boolean toggle, boolean extend)
public void columnAdded(TableColumnModelEvent event)
Invoked when the column is added. Revalidates and repains the table.
- 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)
Invoked when the column margin is changed. Revalidates and repains the table.
- Specified by:
- columnMarginChanged in interface TableColumnModelListener
public void columnMoved(TableColumnModelEvent event)
Invoked when the column is moved. Revalidates and repains the table.
- Specified by:
- columnMoved in interface TableColumnModelListener
public void columnRemoved(TableColumnModelEvent event)
Invoked when the column is removed. Revalidates and repains the table.
- Specified by:
- columnRemoved in interface TableColumnModelListener
public void columnSelectionChanged(ListSelectionEvent event)
Invoked when the the column selection changes, repaints the changed columns. It is not recommended to override this method, register the listener instead.
- Specified by:
- columnSelectionChanged in interface TableColumnModelListener
public int convertColumnIndexToModel(int vc)
Convert the table model index into the table column number. The model number need not match the real column position. The columns may be rearranged by the user with mouse at any time by dragging the column headers.
- Parameters:
vc
- the column number (0=first).
- Returns:
- the table column model index of this column.
- See Also:
TableColumn.getModelIndex()
public int convertColumnIndexToView(int mc)
Convert the table column number to the table column model index. The model number need not match the real column position. The columns may be rearranged by the user with mouse at any time by dragging the column headers.
- Parameters:
mc
- the table column index (0=first).
- Returns:
- the table column number in the model
- See Also:
TableColumn.getModelIndex()
protected TableColumnModel createDefaultColumnModel()
Create the default table column model that is used if the user-defined column model is not provided. The default method createsDefaultTableColumnModel
.
- Returns:
- the created table column model.
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.
protected TableModel createDefaultDataModel()
Create the default table data model that is used if the user-defined data model is not provided. The default method createsDefaultTableModel
.
- Returns:
- the created table data model.
protected void createDefaultEditors()
Create the default editors for this table. The default method creates the editor for Booleans. Other fields are edited as strings at the moment.
protected void createDefaultRenderers()
Create the default renderers for this table. The default method creates renderers for Boolean, Number, Double, Date, Icon and ImageIcon.
protected ListSelectionModel createDefaultSelectionModel()
Create the default table selection model that is used if the user-defined selection model is not provided. The default method createsDefaultListSelectionModel
.
- Returns:
- the created table data model.
protected JTableHeader createDefaultTableHeader()
Create the default table header, if the user - defined table header is not provided.
- Returns:
- the default table header.
public static JScrollPane createScrollPaneForTable(JTable table)
Deprecated. 1.0.2, replaced by
new JScrollPane(JTable)
public void doLayout()
Set the widths of all columns, taking they preferred widths into consideration. The excess space, if any, will be distrubuted between all columns. This method also handles special cases when one of the collumns is currently being resized.
- See Also:
TableColumn.setPreferredWidth(int)
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)
Invoked when the editing is cancelled.
- Specified by:
- editingCanceled in interface CellEditorListener
public void editingStopped(ChangeEvent event)
Finish the current editing session and update the table with the new value by callingsetValueAt(Object,int,int)
.
- Specified by:
- editingStopped in interface CellEditorListener
- Parameters:
event
- the change event
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 TableCellEditor getCellEditor(int row, int column)
Get the cell editor, suitable for editing the given cell. The default method requests the editor from the column model. If the column model does not provide the editor, the call is forwarded to thegetDefaultEditor(Class)
with the parameter, obtained fromTableModel.getColumnClass(int)
.
- Parameters:
row
- the cell rowcolumn
- the cell column
- Returns:
- the editor to edit that cell
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 TableCellRenderer getCellRenderer(int row, int column)
Get the cell renderer for rendering the given cell.
- Parameters:
row
- the cell rowcolumn
- the cell column
- Returns:
- the cell renderer to render that cell.
public boolean getCellSelectionEnabled()
Get the value of thecellSelectionEnabled
property.
- Returns:
- The current value of the property
public TableColumn getColumn(Object identifier)
Get table column with the given identified.
- Parameters:
identifier
- the column identifier
- Returns:
- the table column with this identifier
- Throws:
IllegalArgumentException
- ifidentifier
isnull
or there is no column with that identifier.
- See Also:
TableColumn.setIdentifier(Object)
public Class> getColumnClass(int column)
Get the class (datatype) of the column. The cells are rendered and edited differently, depending from they data type.
- Parameters:
column
- the column (not the model index).
- Returns:
- the class, defining data type of that column (String.class for String, Boolean.class for boolean and so on).
public int getColumnCount()
Get the value of thecolumnCount
property by delegation to thecolumnModel
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 String getColumnName(int column)
Get the name of the column. If the column has the column identifier set, the return value is the result of the .toString() method call on that identifier. If the identifier is not explicitly set, the returned value is calculated byAbstractTableModel.getColumnName(int)
.
- Parameters:
column
- the column
- Returns:
- the name of that column.
public boolean getColumnSelectionAllowed()
Get the value of thecolumnSelectionAllowed
property.
- Returns:
- The current value of the columnSelectionAllowed property
- See Also:
setColumnSelectionAllowed(boolean)
public TableCellEditor getDefaultEditor(Class> columnClass)
Get the default editor for editing values of the given type (String, Boolean and so on).
- Parameters:
columnClass
- the class of the value that will be edited.
- Returns:
- the editor, suitable for editing this data type
public TableCellRenderer getDefaultRenderer(Class> columnClass)
Get the default renderer for rendering the given data type.
- Parameters:
columnClass
- the data that must be rendered
- Returns:
- the appropriate defauld renderer for rendering that data type.
public boolean getDragEnabled()
Get the value of thedragEnabled
property.
- Returns:
- The current value of the property
public int getEditingColumn()
Get the column, currently being edited
- Returns:
- the column, currently being edited.
public int getEditingRow()
Get the row currently being edited.
- Returns:
- the row, currently being edited.
public Component getEditorComponent()
Get the editor component that is currently editing one of the cells
- Returns:
- the editor component or null, if none of the cells is being edited.
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 thedataModel
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
- See Also:
setRowSelectionAllowed(boolean)
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)
Return the preferred scrolling amount (in pixels) for the given scrolling direction and orientation. This method handles a partially exposed row by returning the distance required to completely expose the item. When scrolling the top item is completely exposed.
- Specified by:
- getScrollableUnitIncrement in interface Scrollable
- Parameters:
visibleRect
- the currently visible part of the component.orientation
- the scrolling orientationdirection
- the scrolling direction (negative - up, positive -down). The values greater than one means that more mouse wheel or similar events were generated, and hence it is better to scroll the longer distance.
public int getSelectedColumn()
Get the value of theselectedColumn
property by delegation to thecolumnModel
field.
- Returns:
- The current value of the selectedColumn property
public int getSelectedColumnCount()
Get the value of theselectedColumnCount
property by delegation to thecolumnModel
field.
- Returns:
- The current value of the selectedColumnCount property
public int[] getSelectedColumns()
Get the value of theselectedColumns
property by delegation to thecolumnModel
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 theselectionModel
field.
- Returns:
- The current value of the selectedRowCount property
public int[] getSelectedRows()
Get the value of theselectedRows
property by delegation to theselectionModel
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 Object getValueAt(int row, int column)
Get the cell value at the given position.
- Parameters:
row
- the row to get the valuecolumn
- the actual column number (not the model index) to get the value.
- Returns:
- the cell value, as returned by model.
protected void initializeLocalVars()
Initialize local variables to default values.
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:
- true if the cell is editable, false otherwise.
public boolean isCellSelected(int row, int column)
Checks if the given cell is selected. The cell is selected if both the cell row and the cell column are selected.
- Parameters:
row
- the cell rowcolumn
- the cell column
- Returns:
- true if the cell is selected, false otherwise
public boolean isColumnSelected(int column)
Checks if the given column is selected.
- Parameters:
column
- the column
- Returns:
- true if the column is selected (as reported by the selection model, associated with the column model), false otherwise.
public boolean isEditing()
Check if one of the table cells is currently being edited.
- Returns:
- true if there is a cell being edited.
public boolean isRowSelected(int row)
Checks if the given row is selected.
- Parameters:
row
- the row
- Returns:
- true if the row is selected (as reported by the selection model), false otherwise.
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 Component prepareRenderer(TableCellRenderer renderer, int row, int column)
Prepare the renderer for rendering the given cell.
- Parameters:
renderer
- the renderer being preparedrow
- the row of the cell being renderedcolumn
- the column of the cell being rendered
- Returns:
- the component which .paint() method will paint the cell.
public void removeColumn(TableColumn column)
Removes specified column from displayable columns of this table.
- Parameters:
column
- column to removed
public void removeNotify()
Called to inform this component is has been removed from its container. Its native peer - if any - is destroyed at this time. This method is called automatically by the AWT system and should not be called by user level code.
- 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
- See Also:
getColumnSelectionAllowed()
public void setDefaultEditor(Class> columnClass, TableCellEditor editor)
Set the default editor for the given column class (column data type). By default, String is handled by text field and Boolean is handled by the check box.
- Parameters:
columnClass
- the column data typeeditor
- the editor that will edit this data type
- See Also:
TableModel.getColumnClass(int)
public void setDefaultRenderer(Class> columnClass, TableCellRenderer rend)
Set default renderer for rendering the given data type.
- Parameters:
columnClass
- the data type (String, Boolean and so on) that must be rendered.rend
- the renderer that will rend this data type
public void setDragEnabled(boolean d)
Set the value of thedragEnabled
property.
- Parameters:
d
- The new value of the dragEnabled property
public void setEditingColumn(int column)
Set the column, currently being edited
- Parameters:
column
- the column, currently being edited.
public void setEditingRow(int row)
Set the row currently being edited.
- Parameters:
row
- the row, that will be edited
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)
Sets the height for all rows in the table. If you want to change the height of a single row instead, usesetRowHeight(int,int)
.
- Parameters:
r
- the height to set for all rows
- See Also:
getRowHeight()
,setRowHeight(int,int)
,getRowHeight(int)
public void setRowHeight(int row, int rh)
Sets the height of a single row in the table.
- Parameters:
row
- the row to change the height ofrh
- the new row height
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
- See Also:
getRowSelectionAllowed()
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 setValueAt(Object value, int row, int column)
Set value for the cell at the given position. The modified cell is repainted.
- Parameters:
value
- the value to setrow
- the row of the cell being modifiedcolumn
- the column of the cell being modified
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)
Invoked when the table changes.null
means everything changed.
- Specified by:
- tableChanged in interface TableModelListener
public void valueChanged(ListSelectionEvent event)
Invoked when another table row is selected. It is not recommended to override thid method, register the listener instead.
- Specified by:
- valueChanged in interface ListSelectionListener