|
|||||||||
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
javax.swing.JTable
public class JTable
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 . |
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 |
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 TableColumnModel and assign it to the columnModel
property when the dataModel property is changed. |
protected int |
autoResizeMode
A numeric code specifying the resizing behavior of the table. |
protected TableCellEditor |
cellEditor
The current cell editor. |
protected boolean |
cellSelectionEnabled
Obsolete. |
protected TableColumnModel |
columnModel
A model of various aspects of the columns of the table, not including the data stored in them. |
protected TableModel |
dataModel
The model for data stored in the table. |
protected Hashtable |
defaultEditorsByColumnClass
A table mapping Class objects to
TableCellEditor objects. |
protected Hashtable |
defaultRenderersByColumnClass
A table mapping Class objects to
TableCellEditor objects. |
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 Component |
editorComp
The component that is used for editing. |
protected Color |
gridColor
The color to paint the grid lines of the table, when either showHorizontalLines or showVerticalLines is set. |
protected Dimension |
preferredViewportSize
The size this table would prefer its viewport assume, if it is contained in a JScrollPane . |
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. |
protected Color |
selectionBackground
The color to paint the background of selected cells. |
protected 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. |
protected boolean |
showHorizontalLines
The showHorizontalLines property. |
protected boolean |
showVerticalLines
The showVerticalLines property. |
protected JTableHeader |
tableHeader
The tableHeader property. |
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.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(Object[][] data,
Object[] columnNames)
Creates a new JTable instance, storing the given data
array and heaving the given column names. |
|
JTable(TableModel model)
Creates a new JTable instance, using the given data model
object that provides information about the table content. |
|
JTable(TableModel dm,
TableColumnModel cm)
Creates a new JTable instance, using the given model object
that provides information about the table content. |
|
JTable(TableModel dm,
TableColumnModel cm,
ListSelectionModel sm)
Creates a new JTable instance, providing data model,
column model and list selection model. |
|
JTable(Vector data,
Vector columnNames)
Creates a new JTable instance that uses data and column
names, stored in Vector s. |
Method Summary | |
---|---|
void |
addColumn(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(TableColumnModelEvent event)
Invoked when the column is added. |
int |
columnAtPoint(Point point)
Returns index of the column that contains specified point or -1 if this table doesn't contain this point. |
void |
columnMarginChanged(ChangeEvent event)
Invoked when the column margin is changed. |
void |
columnMoved(TableColumnModelEvent event)
Invoked when the column is moved. |
void |
columnRemoved(TableColumnModelEvent event)
Invoked when the column is removed. |
void |
columnSelectionChanged(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. |
protected 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
TableColumnModel 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. |
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 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) |
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,
EventObject e)
Programmatically starts editing the specified cell. |
void |
editingCanceled(ChangeEvent event)
Invoked when the editing is cancelled. |
void |
editingStopped(ChangeEvent event)
Finish the current editing session and update the table with the new value by calling setValueAt(java.lang.Object, int, int) . |
AccessibleContext |
getAccessibleContext()
Get the value of the JComponent.accessibleContext property. |
boolean |
getAutoCreateColumnsFromModel()
Get the value of the autoCreateColumnsFromModel property. |
int |
getAutoResizeMode()
Get the value of the autoResizeMode property. |
TableCellEditor |
getCellEditor()
Get the value of the cellEditor property. |
TableCellEditor |
getCellEditor(int row,
int column)
Get the cell editor, suitable for editing the given cell. |
Rectangle |
getCellRect(int row,
int column,
boolean includeSpacing)
Calculate the visible rectangle for a particular row and column. |
TableCellRenderer |
getCellRenderer(int row,
int column)
Get the cell renderer for rendering the given cell. |
boolean |
getCellSelectionEnabled()
Get the value of the cellSelectionEnabled property. |
TableColumn |
getColumn(Object identifier)
Get table column with the given identified. |
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 field. |
TableColumnModel |
getColumnModel()
Get the value of the columnModel property. |
String |
getColumnName(int column)
Get the name of the column. |
boolean |
getColumnSelectionAllowed()
Get the value of the columnSelectionAllowed property. |
TableCellEditor |
getDefaultEditor(Class<?> columnClass)
Get the default editor for editing values of the given type (String, Boolean and so on). |
TableCellRenderer |
getDefaultRenderer(Class<?> columnClass)
Get the default renderer for rendering the given data type. |
boolean |
getDragEnabled()
Get the value of the dragEnabled property. |
int |
getEditingColumn()
Get the column, currently being edited |
int |
getEditingRow()
Get the row currently being edited. |
Component |
getEditorComponent()
Get the editor component that is currently editing one of the cells |
Color |
getGridColor()
Get the value of the gridColor property. |
Dimension |
getIntercellSpacing()
Get the value of the intercellSpacing property. |
TableModel |
getModel()
Get the value of the dataModel property. |
Dimension |
getPreferredScrollableViewportSize()
Get the value of the preferredViewportSize property. |
int |
getRowCount()
Get the value of the rowCount property by
delegation to the dataModel field. |
int |
getRowHeight()
Get the value of the rowHeight property. |
int |
getRowHeight(int row)
Get the height of the specified row. |
int |
getRowMargin()
Get the value of the rowMargin property. |
boolean |
getRowSelectionAllowed()
Get the value of the rowSelectionAllowed property. |
int |
getScrollableBlockIncrement(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(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 field. |
int |
getSelectedColumnCount()
Get the value of the selectedColumnCount property by
delegation to the columnModel field. |
int[] |
getSelectedColumns()
Get the value of the selectedColumns property by
delegation to the columnModel field. |
int |
getSelectedRow()
Get the value of the selectedRow property by delegation to the ListSelectionModel.getMinSelectionIndex() method of the
selectionModel field. |
int |
getSelectedRowCount()
Get the value of the selectedRowCount property by
delegation to the selectionModel field. |
int[] |
getSelectedRows()
Get the value of the selectedRows property by
delegation to the selectionModel field. |
Color |
getSelectionBackground()
Get the value of the selectionBackground property. |
Color |
getSelectionForeground()
Get the value of the selectionForeground property. |
ListSelectionModel |
getSelectionModel()
Get the value of the selectionModel property. |
boolean |
getShowHorizontalLines()
Get the value of the showHorizontalLines property. |
boolean |
getShowVerticalLines()
Get the value of the showVerticalLines property. |
boolean |
getSurrendersFocusOnKeystroke()
Returns whether cell editors of this table should receive keyboard focus when the editor is activated by a keystroke. |
JTableHeader |
getTableHeader()
Get the value of the tableHeader property. |
TableUI |
getUI()
This method returns the table's UI delegate. |
String |
getUIClassID()
Get the value of the UIClassID property. |
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. |
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). |
Component |
prepareRenderer(TableCellRenderer renderer,
int row,
int column)
Prepare the renderer for rendering the given cell. |
void |
removeColumn(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(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 flag. |
void |
setAutoResizeMode(int a)
Set the value of the autoResizeMode property. |
void |
setCellEditor(TableCellEditor c)
Set the value of the cellEditor property. |
void |
setCellSelectionEnabled(boolean c)
Set the value of the cellSelectionEnabled property. |
void |
setColumnModel(TableColumnModel c)
Set the value of the columnModel property. |
void |
setColumnSelectionAllowed(boolean c)
Set the value of the columnSelectionAllowed property. |
void |
setColumnSelectionInterval(int index0,
int index1)
|
void |
setDefaultEditor(Class<?> columnClass,
TableCellEditor editor)
Set the default editor for the given column class (column data type). |
void |
setDefaultRenderer(Class<?> columnClass,
TableCellRenderer rend)
Set default renderer for rendering the given data type. |
void |
setDragEnabled(boolean d)
Set the value of the dragEnabled property. |
void |
setEditingColumn(int column)
Set the column, currently being edited |
void |
setEditingRow(int row)
Set the row currently being edited. |
void |
setGridColor(Color g)
Set the value of the gridColor property. |
void |
setIntercellSpacing(Dimension i)
Set the value of the intercellSpacing property. |
void |
setModel(TableModel m)
Set the value of the dataModel property. |
void |
setPreferredScrollableViewportSize(Dimension p)
Set the value of the preferredViewportSize property. |
void |
setRowHeight(int r)
Sets the height for all rows in the table. |
void |
setRowHeight(int row,
int rh)
Sets the height of a single row in the table. |
void |
setRowMargin(int r)
Set the value of the rowMargin property. |
void |
setRowSelectionAllowed(boolean r)
Set the value of the rowSelectionAllowed property. |
void |
setRowSelectionInterval(int index0,
int index1)
|
void |
setSelectionBackground(Color s)
Set the value of the selectionBackground property. |
void |
setSelectionForeground(Color s)
Set the value of the selectionForeground property. |
void |
setSelectionMode(int s)
Set the value of the selectionMode property by
delegation to the selectionModel field. |
void |
setSelectionModel(ListSelectionModel s)
Set the value of the selectionModel property. |
void |
setShowGrid(boolean s)
Set the value of the showGrid property. |
void |
setShowHorizontalLines(boolean s)
Set the value of the showHorizontalLines property. |
void |
setShowVerticalLines(boolean s)
Set the value of the showVerticalLines 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(JTableHeader t)
Set the value of the tableHeader property. |
void |
setUI(TableUI ui)
This method sets the table's UI delegate. |
void |
setValueAt(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(TableModelEvent event)
Invoked when the table changes. |
protected void |
unconfigureEnclosingScrollPane()
|
void |
updateUI()
This method should be overridden in subclasses. |
void |
valueChanged(ListSelectionEvent event)
Invoked when another table row is selected. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int AUTO_RESIZE_OFF
JScrollPane
in order to
accomodate cases in which the table size exceeds its visible area.
public static final int AUTO_RESIZE_NEXT_COLUMN
i
, automatically change only the
single column i+1
to provide or absorb excess space
requirements.
public static final int AUTO_RESIZE_SUBSEQUENT_COLUMNS
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.
public static final int AUTO_RESIZE_ALL_COLUMNS
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.
public static final int AUTO_RESIZE_LAST_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.
protected Hashtable defaultEditorsByColumnClass
Class
objects to
TableCellEditor
objects. This table is consulted by the
FIXME
protected Hashtable defaultRenderersByColumnClass
Class
objects to
TableCellEditor
objects. This table is consulted by the
FIXME
protected int editingColumn
protected int editingRow
protected transient Component editorComp
null
if the table is not editing currently.
protected boolean autoCreateColumnsFromModel
TableColumnModel
and assign it to the columnModel
property when the dataModel
property is changed.
setModel(TableModel)
,
createDefaultColumnsFromModel()
,
setColumnModel(TableColumnModel)
,
setAutoCreateColumnsFromModel(boolean)
,
getAutoCreateColumnsFromModel()
protected int autoResizeMode
AUTO_RESIZE_ALL_COLUMNS
(the default), AUTO_RESIZE_LAST_COLUMN
, AUTO_RESIZE_NEXT_COLUMN
, AUTO_RESIZE_SUBSEQUENT_COLUMNS
, or AUTO_RESIZE_OFF
.
doLayout()
,
setAutoResizeMode(int)
,
getAutoResizeMode()
protected int rowHeight
columnModel
.
getRowHeight()
,
setRowHeight(int)
,
TableColumn.getWidth()
,
TableColumn.setWidth(int)
protected int rowMargin
setRowMargin(int)
,
getRowHeight()
,
getIntercellSpacing()
,
setIntercellSpacing(Dimension)
,
TableColumnModel.getColumnMargin()
,
TableColumnModel.setColumnMargin(int)
protected boolean rowSelectionAllowed
TableColumnModel.getColumnSelectionAllowed()
,
setRowSelectionAllowed(boolean)
,
getRowSelectionAllowed()
,
getCellSelectionEnabled()
,
setCellSelectionEnabled(boolean)
protected boolean cellSelectionEnabled
rowSelectionAllowed
, getColumnSelectionAllowed()
, or the combined methods getCellSelectionEnabled()
and setCellSelectionEnabled(boolean)
.
protected TableModel dataModel
dataModel
, despite its
property name. The table listens to its model as a TableModelListener
.
tableChanged(TableModelEvent)
,
TableModel.addTableModelListener(TableModelListener)
protected TableColumnModel columnModel
A model of various aspects of the columns of the table, not
including the data stored in them. The TableColumnModel
is principally concerned with holding a set of TableColumn
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 a ListSelectionModel
which
indicates which columns are currently selected. This selection model
works in combination with the selectionModel
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: setting autoCreateColumnsFromModel
will construct the
columnModel automatically, and the table acts as a facade for most of
the interesting properties of the columnModel anyways.
setColumnModel(TableColumnModel)
,
getColumnModel()
protected ListSelectionModel selectionModel
columnModel
property, to represent the rows and
columns (or both: cells) of the table which are currently selected.
rowSelectionAllowed
,
setSelectionModel(ListSelectionModel)
,
getSelectionModel()
,
TableColumnModel.getSelectionModel()
,
ListSelectionModel.addListSelectionListener(ListSelectionListener)
protected TableCellEditor cellEditor
protected Color gridColor
showHorizontalLines
or showVerticalLines
is set.
setGridColor(Color)
,
getGridColor()
protected Dimension preferredViewportSize
JScrollPane
.
setPreferredScrollableViewportSize(Dimension)
,
getPreferredScrollableViewportSize()
protected Color selectionBackground
SELECTION_BACKGROUND_CHANGED_PROPERTY
when its value changes.
setSelectionBackground(Color)
,
getSelectionBackground()
protected Color selectionForeground
SELECTION_FOREGROUND_CHANGED_PROPERTY
when its value changes.
setSelectionForeground(Color)
,
getSelectionForeground()
protected boolean showHorizontalLines
protected boolean showVerticalLines
protected JTableHeader tableHeader
Constructor Detail |
---|
public JTable()
JTable
instance.
public JTable(int numRows, int numColumns)
JTable
instance with the given number
of rows and columns.
numRows
- an int
valuenumColumns
- an int
valuepublic JTable(Object[][] data, Object[] columnNames)
JTable
instance, storing the given data
array and heaving the given column names. To see the column names,
you must place the JTable into the JScrollPane
.
data
- an Object[][]
the table datacolumnNames
- an Object[]
the column headerspublic JTable(TableModel model)
JTable
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.
model
- the table model.public JTable(TableModel dm, TableColumnModel cm)
JTable
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.
dm
- the table data modecm
- the table column modelpublic JTable(TableModel dm, TableColumnModel cm, ListSelectionModel sm)
JTable
instance, providing data model,
column model and list selection model. The list selection model
manages the selections.
dm
- data model (manages table data)cm
- column model (manages table columns)sm
- list selection model (manages table selections)public JTable(Vector data, Vector columnNames)
JTable
instance that uses data and column
names, stored in Vector
s.
data
- the table datacolumnNames
- the table column names.Method Detail |
---|
protected void initializeLocalVars()
public void addColumn(TableColumn column)
column
- the new column to add.protected void createDefaultEditors()
protected void createDefaultRenderers()
public static JScrollPane createScrollPaneForTable(JTable table)
new JScrollPane(JTable)
protected TableColumnModel createDefaultColumnModel()
DefaultTableColumnModel
.
protected TableModel createDefaultDataModel()
DefaultTableModel
.
protected ListSelectionModel createDefaultSelectionModel()
DefaultListSelectionModel
.
protected JTableHeader createDefaultTableHeader()
public void columnAdded(TableColumnModelEvent event)
columnAdded
in interface TableColumnModelListener
event
- information about the column addition.public void columnMarginChanged(ChangeEvent event)
columnMarginChanged
in interface TableColumnModelListener
event
- the event (identifies the source).public void columnMoved(TableColumnModelEvent event)
columnMoved
in interface TableColumnModelListener
event
- information about the column move.public void columnRemoved(TableColumnModelEvent event)
columnRemoved
in interface TableColumnModelListener
event
- information about the column removal.public void columnSelectionChanged(ListSelectionEvent event)
columnSelectionChanged
in interface TableColumnModelListener
event
- information about the column selection state.public void editingCanceled(ChangeEvent event)
editingCanceled
in interface CellEditorListener
event
- Change Eventpublic void editingStopped(ChangeEvent event)
setValueAt(java.lang.Object, int, int)
.
editingStopped
in interface CellEditorListener
event
- the change eventpublic void tableChanged(TableModelEvent event)
null
means everything changed.
tableChanged
in interface TableModelListener
event
- contains details of the update.public void valueChanged(ListSelectionEvent event)
valueChanged
in interface ListSelectionListener
event
- the event.public int columnAtPoint(Point point)
point
- point to identify the column
public int rowAtPoint(Point point)
point
- point to identify the row
public Rectangle getCellRect(int row, int column, boolean includeSpacing)
dataModel
column.
row
- the visible row to get the cell rectangle ofcolumn
- the visible column to get the cell rectangle of, which may
differ from the dataModel
columnincludeSpacing
- whether or not to include the cell margins in the
resulting cell. If false
, the result will only contain the
inner area of the target cell, not including its margins.
public void clearSelection()
public int getSelectedRow()
ListSelectionModel.getMinSelectionIndex()
method of the
selectionModel
field.
public ListSelectionModel getSelectionModel()
selectionModel
property.
public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction)
Scrollable
getScrollableBlockIncrement
in interface Scrollable
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 boolean getScrollableTracksViewportHeight()
scrollableTracksViewportHeight
property.
getScrollableTracksViewportHeight
in interface Scrollable
false
public boolean getScrollableTracksViewportWidth()
scrollableTracksViewportWidth
property.
getScrollableTracksViewportWidth
in interface Scrollable
true
unless the autoResizeMode
property is
AUTO_RESIZE_OFF
public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction)
getScrollableUnitIncrement
in interface Scrollable
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 TableCellEditor getCellEditor(int row, int column)
getDefaultEditor(Class)
with the parameter, obtained from
TableModel.getColumnClass(int)
.
row
- the cell rowcolumn
- the cell column
public TableCellEditor getDefaultEditor(Class<?> columnClass)
columnClass
- the class of the value that will be edited.
public TableCellRenderer getCellRenderer(int row, int column)
row
- the cell rowcolumn
- the cell column
public void setDefaultRenderer(Class<?> columnClass, TableCellRenderer rend)
columnClass
- the data type (String, Boolean and so on) that must be
rendered.rend
- the renderer that will rend this data typepublic TableCellRenderer getDefaultRenderer(Class<?> columnClass)
columnClass
- the data that must be rendered
public int convertColumnIndexToModel(int vc)
vc
- the column number (0=first).
TableColumn.getModelIndex()
public int convertColumnIndexToView(int mc)
mc
- the table column index (0=first).
TableColumn.getModelIndex()
public Component prepareRenderer(TableCellRenderer renderer, int row, int column)
renderer
- the renderer being preparedrow
- the row of the cell being renderedcolumn
- the column of the cell being rendered
public boolean getAutoCreateColumnsFromModel()
autoCreateColumnsFromModel
property.
public int getAutoResizeMode()
autoResizeMode
property.
public int getRowHeight()
rowHeight
property.
public int getRowHeight(int row)
row
- the row whose height to returnpublic int getRowMargin()
rowMargin
property.
public boolean getRowSelectionAllowed()
rowSelectionAllowed
property.
setRowSelectionAllowed(boolean)
public boolean getCellSelectionEnabled()
cellSelectionEnabled
property.
public TableModel getModel()
dataModel
property.
public int getColumnCount()
columnCount
property by
delegation to the columnModel
field.
public int getRowCount()
rowCount
property by
delegation to the dataModel
field.
public TableColumnModel getColumnModel()
columnModel
property.
public int getSelectedColumn()
selectedColumn
property by
delegation to the columnModel
field.
public int getSelectedColumnCount()
selectedColumnCount
property by
delegation to the columnModel
field.
public int[] getSelectedColumns()
selectedColumns
property by
delegation to the columnModel
field.
public boolean getColumnSelectionAllowed()
columnSelectionAllowed
property.
setColumnSelectionAllowed(boolean)
public int getSelectedRowCount()
selectedRowCount
property by
delegation to the selectionModel
field.
public int[] getSelectedRows()
selectedRows
property by
delegation to the selectionModel
field.
public AccessibleContext getAccessibleContext()
JComponent.accessibleContext
property.
getAccessibleContext
in interface Accessible
getAccessibleContext
in class JComponent
public TableCellEditor getCellEditor()
cellEditor
property.
public boolean getDragEnabled()
dragEnabled
property.
public Color getGridColor()
gridColor
property.
public Dimension getIntercellSpacing()
intercellSpacing
property.
public Dimension getPreferredScrollableViewportSize()
preferredViewportSize
property.
getPreferredScrollableViewportSize
in interface Scrollable
public Color getSelectionBackground()
selectionBackground
property.
public Color getSelectionForeground()
selectionForeground
property.
public boolean getShowHorizontalLines()
showHorizontalLines
property.
public boolean getShowVerticalLines()
showVerticalLines
property.
public JTableHeader getTableHeader()
tableHeader
property.
public void removeColumn(TableColumn column)
column
- column to removedpublic void moveColumn(int column, int targetColumn)
column
- index of the column to movetargetColumn
- index specifying new location of the columnpublic void setAutoCreateColumnsFromModel(boolean autoCreate)
autoCreateColumnsFromModel
flag. If the
flag changes from false
to true
, the
createDefaultColumnsFromModel()
method is called.
autoCreate
- the new value of the flag.public void setAutoResizeMode(int a)
autoResizeMode
property.
a
- The new value of the autoResizeMode propertypublic void setRowHeight(int r)
setRowHeight(int, int)
.
r
- the height to set for all rowsgetRowHeight()
,
setRowHeight(int, int)
,
getRowHeight(int)
public void setRowHeight(int row, int rh)
rh
- the new row heightrow
- the row to change the height ofpublic void setRowMargin(int r)
rowMargin
property.
r
- The new value of the rowMargin propertypublic void setRowSelectionAllowed(boolean r)
rowSelectionAllowed
property.
r
- The new value of the rowSelectionAllowed propertygetRowSelectionAllowed()
public void setCellSelectionEnabled(boolean c)
cellSelectionEnabled
property.
c
- The new value of the cellSelectionEnabled propertypublic void setModel(TableModel m)
Set the value of the dataModel
property.
Unregister this
as a TableModelListener
from
previous dataModel
and register it with new parameter
m
.
m
- The new value of the model propertypublic void setColumnModel(TableColumnModel c)
Set the value of the columnModel
property.
Unregister this
as a TableColumnModelListener
from previous columnModel
and register it with new parameter
c
.
c
- The new value of the columnModel propertypublic void setColumnSelectionAllowed(boolean c)
columnSelectionAllowed
property.
c
- The new value of the propertygetColumnSelectionAllowed()
public void setSelectionModel(ListSelectionModel s)
Set the value of the selectionModel
property.
Unregister this
as a ListSelectionListener
from previous selectionModel
and register it with new
parameter s
.
s
- The new value of the selectionModel propertypublic void setSelectionMode(int s)
selectionMode
property by
delegation to the selectionModel
field. The same selection
mode is set for row and column selection models.
s
- The new value of the propertypublic void setCellEditor(TableCellEditor c)
Set the value of the cellEditor
property.
Unregister this
as a CellEditorListener
from
previous cellEditor
and register it with new parameter
c
.
c
- The new value of the cellEditor propertypublic void setDragEnabled(boolean d)
dragEnabled
property.
d
- The new value of the dragEnabled propertypublic void setGridColor(Color g)
gridColor
property.
g
- The new value of the gridColor propertypublic void setIntercellSpacing(Dimension i)
intercellSpacing
property.
i
- The new value of the intercellSpacing propertypublic void setPreferredScrollableViewportSize(Dimension p)
preferredViewportSize
property.
p
- The new value of the preferredViewportSize propertypublic void setSelectionBackground(Color s)
Set the value of the selectionBackground
property.
Fire a PropertyChangeEvent with name SELECTION_BACKGROUND_CHANGED_PROPERTY
to registered listeners, if
selectionBackground changed.
s
- The new value of the selectionBackground propertypublic void setSelectionForeground(Color s)
Set the value of the selectionForeground
property.
Fire a PropertyChangeEvent with name SELECTION_FOREGROUND_CHANGED_PROPERTY
to registered listeners, if
selectionForeground changed.
s
- The new value of the selectionForeground propertypublic void setShowGrid(boolean s)
showGrid
property.
s
- The new value of the showGrid propertypublic void setShowHorizontalLines(boolean s)
showHorizontalLines
property.
s
- The new value of the showHorizontalLines propertypublic void setShowVerticalLines(boolean s)
showVerticalLines
property.
s
- The new value of the showVerticalLines propertypublic void setTableHeader(JTableHeader t)
tableHeader
property.
t
- The new value of the tableHeader propertyprotected void configureEnclosingScrollPane()
protected void unconfigureEnclosingScrollPane()
public void addNotify()
JComponent
addNotify
in class JComponent
Component.isDisplayable()
,
Component.removeNotify()
public void removeNotify()
JComponent
Component.getParent()
.
removeNotify
in class JComponent
Component.isDisplayable()
,
Component.addNotify()
public void doLayout()
doLayout
in class Container
TableColumn.setPreferredWidth(int)
public void sizeColumnsToFit(boolean lastColumnOnly)
doLayout()
public void sizeColumnsToFit(int resizingColumn)
doLayout()
.
public String getUIClassID()
JComponent
UIDefaults
table managed by UIManager
, the
value of which is the name of a class to load for the component's
JComponent.ui
property.
getUIClassID
in class JComponent
"ComponentUI"
JComponent.setUI(javax.swing.plaf.ComponentUI)
,
JComponent.updateUI()
public TableUI getUI()
public void setUI(TableUI ui)
ui
- The table's UI delegate.public void updateUI()
JComponent
JComponent.getUIClassID()
) from the UIManager
, and calls JComponent.setUI(javax.swing.plaf.ComponentUI)
with the new delegate.
updateUI
in class JComponent
public Class<?> getColumnClass(int column)
column
- the column (not the model index).
public String getColumnName(int column)
AbstractTableModel.getColumnName(int)
.
column
- the column
public int getEditingColumn()
public void setEditingColumn(int column)
column
- the column, currently being edited.public int getEditingRow()
public void setEditingRow(int row)
row
- the row, that will be editedpublic Component getEditorComponent()
public boolean isEditing()
public void setDefaultEditor(Class<?> columnClass, TableCellEditor editor)
columnClass
- the column data typeeditor
- the editor that will edit this data typeTableModel.getColumnClass(int)
public void addColumnSelectionInterval(int index0, int index1)
public void addRowSelectionInterval(int index0, int index1)
public void setColumnSelectionInterval(int index0, int index1)
public void setRowSelectionInterval(int index0, int index1)
public void removeColumnSelectionInterval(int index0, int index1)
public void removeRowSelectionInterval(int index0, int index1)
public boolean isColumnSelected(int column)
column
- the column
public boolean isRowSelected(int row)
row
- the row
public boolean isCellSelected(int row, int column)
row
- the cell rowcolumn
- the cell column
public void selectAll()
public Object getValueAt(int row, int column)
row
- the row to get the valuecolumn
- the actual column number (not the model index)
to get the value.
public void setValueAt(Object value, int row, int column)
value
- the value to setrow
- the row of the cell being modifiedcolumn
- the column of the cell being modifiedpublic TableColumn getColumn(Object identifier)
identifier
- the column identifier
IllegalArgumentException
- if identifier
is
null
or there is no column with that identifier.TableColumn.setIdentifier(Object)
public boolean isCellEditable(int row, int column)
true
if the specified cell is editable, and
false
otherwise.
row
- the row index.column
- the column index.
public void createDefaultColumnsFromModel()
JTable
's
TableColumnModel
and creates new columns to match the values in
the data (TableModel
) used by the table.
setAutoCreateColumnsFromModel(boolean)
public void changeSelection(int rowIndex, int columnIndex, boolean toggle, boolean extend)
public boolean editCellAt(int row, int column)
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)
row
- the row of the cell to edit.column
- the column of the cell to edit.public void removeEditor()
public Component prepareEditor(TableCellEditor editor, int row, int column)
editor
- the TableCellEditor to set uprow
- the row of the cell to editcolumn
- the column of the cell to edit
protected void resizeAndRepaint()
JTable
and queues a repaint.
public void setSurrendersFocusOnKeystroke(boolean value)
false
which means that the table should keep the keyboard
focus until the cell is selected by a mouse click.
value
- the value to setpublic boolean getSurrendersFocusOnKeystroke()
false
which means that the table should keep the keyboard
focus until the cell is selected by a mouse click.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |