All Packages Class Hierarchy This Package Previous Next Index
Class com.sun.java.swing.table.JTable
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Container
|
+----com.sun.java.swing.JComponent
|
+----com.sun.java.swing.table.JTable
- public class JTable
- extends JComponent
- implements TableModelListener, TableColumnModelListener, ListSelectionListener
-
cellEditor
-
-
columnModel
- The TableColumnModel of the table
-
dataModel
- The TableDataModel of the table
-
editingColumn
-
-
editingRow
-
-
emptySelectionAllowed
- Empty selection allowed in this table
-
gridColor
- The color of the grid
-
isRowSelected
-
-
multipleSelectionAllowed
- Multiple rows selected allowed in this table
-
rowHeight
- The height of all rows in the table
-
rowMargin
- The height margin between rows
-
rowSelectionAllowed
- Row selection allowed in this table
-
selectionModel
- The ListSelectionModel of the table, used to keep track of row selections
-
showGrid
- The table draws a grid between cells if showGrid is true
-
simultaneousRowColumnSelectionAllowed
- If this is true, then both a row selection and a column selection
can be non-empty at the same time.
-
tableHeader
- The TableHeader working with the table
-
JTable()
-
-
JTable(TableDataModel)
-
-
JTable(TableDataModel, TableColumnModel)
-
-
addColumn(JTableColumn)
- Appends aColumn to the end of the JTable's array of columns.
-
addColumnSelectionInterval(int, int)
-
Adds the columns from index0 to index0 inclusive to
the current selection, if column selection and multiple selection
is allowed.
-
addRowSelectionInterval(int, int)
-
Adds the rows from index0 to index0 inclusive to
the current selection, if row selection and multiple selection
is allowed.
-
clearSelection()
- Deselects all selected columns and rows.
-
columnAdded(TableColumnModelEvent)
-
-
columnAtPoint(Point)
- Returns the index of the column that point lies in, or -1 if it
lies outside the receiver's bounds.
-
columnMarginChanged(ChangeEvent)
-
-
columnMoved(TableColumnModelEvent)
-
-
columnRemoved(TableColumnModelEvent)
-
-
columnSelectionChanged(ListSelectionEvent)
-
-
createDefaultColumnModel()
-
-
createDefaultDataModel()
-
-
createDefaultSelectionModel()
-
-
createDefaultTableHeader()
-
-
editColumnRow(int, int)
- Programmatically starts editing the cell at column and row,
if the cell is editable.
-
editingColumn()
- If sent while isEditing() is true, this returns the index of the
editing column; otherwise returns -1.
-
editingRow()
- If sent while isEditing() is true, this returns the index of the
editing row; otherwise returns -1.
-
getCellEditor()
- Set the cellEditor variable
-
getCellRect(int, int, boolean)
- Returns a rectangle locating the cell that lies at the intersection of
column and row.
-
getColumnCount()
- Returns the number of columns in the table
-
getColumnModel()
- Returns the TableColumnModel that contains all column inforamtion
of this table.
-
getColumnSelectionAllowed()
-
-
getEmptySelectionAllowed()
-
-
getGridColor()
- Returns the color used to draw grid lines.
-
getIntercellSpacing()
- Returns the horizontal and vertical spacing between cells.
-
getModel()
- Returns the TableDataModel that provides the data displayed by
the receiver.
-
getMultipleSelectionAllowed()
-
-
getRowCount()
- Returns the number of rows in the table.
-
getRowHeight()
- Returns the height of a table row in the receiver.
-
getRowSelectionAllowed()
-
-
getSelectedColumn()
-
-
getSelectedColumnCount()
-
-
getSelectedColumns()
-
-
getSelectedRow()
-
-
getSelectedRowCount()
-
-
getSelectedRows()
-
-
getSelectionModel()
- Returns the ListSelectionModel that is used to maintain row
selection state.
-
getShowGrid()
- Returns true if the receiver draws grid lines around cells, false if it
doesn't.
-
getSimultaneousRowColumnSelectionAllowed()
-
-
getTableHeader()
- Returns the tableHeader working with this JTable.
-
getUI()
-
-
initializeLocalVars()
-
-
isColumnSelected(int)
-
-
isColumnSelected(Object)
-
-
isEditing()
-
-
isOpaque()
-
-
isRowSelected(int)
-
-
removeColumnSelectionInterval(int, int)
-
Deselects the columns from index0 to index0 inclusive.
-
removeRowSelectionInterval(int, int)
-
Deselects the rows from index0 to index0 inclusive.
-
resizeAndRepaint()
- Properly sizes the receiver and its header view, and marks it as
needing display.
-
rowAtPoint(Point)
- Returns the index of the row that point lies in, or -1 if it lies
outside the receiver's bounds.
-
selectAll()
- If a column is selected, then this selects all columns.
-
setCellEditor(TableCellEditor)
- Set the cellEditor variable
-
setColumnModel(TableColumnModel)
- Sets the column model for this table to newModel and registers
with for listner notifications from the new column model.
-
setColumnSelectionAllowed(boolean)
- Sets whether the columns in this model can be selected.
-
setColumnSelectionInterval(int, int)
-
Selects the columns from index0 to index1 inclusive,
if column selection is allowed.
-
setEditingColumn(int)
- Set the editingColumn variable
-
setEditingRow(int)
- Set the editingRow variable
-
setEmptySelectionAllowed(boolean)
- Sets whether the user can select zero columns or rows.
-
setGridColor(Color)
- Sets the color used to draw grid lines to color and redisplays
the receiver.
-
setIntercellSpacing(Dimension)
- Sets the width and height between cells to newSpacing and
redisplays the receiver.
-
setModel(TableDataModel)
- Sets the data model for this table to newModel and registers
with for listner notifications from the new data model.
-
setMultipleSelectionAllowed(boolean)
- Sets whether the user can select more than one column or row at a time.
-
setRowHeight(int)
- Sets the height for rows to newRowHeight and invokes tile
-
setRowSelectionAllowed(boolean)
- Sets whether the rows in this model can be selected.
-
setRowSelectionInterval(int, int)
-
Selects the rows from index0 to index1 inclusive,
if row selection is allowed.
-
setSelectionModel(ListSelectionModel)
- Sets the row selection model for this table to newModel
and registers with for listner notifications from the new selection model.
-
setShowGrid(boolean)
- Sets whether the receiver draws grid lines around cells.
-
setSimultaneousRowColumnSelectionAllowed(boolean)
- Sets whether this table allows both a column selection and a
row selection to exist at the same time.
-
setTableHeader(JTableHeader)
- Sets the tableHeader working with this JTable to newHeader.
-
setUI(TableUI)
-
-
setValueForEditingCell(Object)
-
-
tableCellChanged(TableModelEvent)
-
-
tableChanged(TableModelEvent)
-
-
tableRowsChanged(TableModelEvent)
-
-
tableRowsInserted(TableModelEvent)
-
-
tableRowsRemoved(TableModelEvent)
-
-
updateUI()
- Called to replace the UI with the latest version from the
default UIFactory.
-
valueChanged(ListSelectionEvent)
-
dataModel
protected TableDataModel dataModel
- The TableDataModel of the table
columnModel
protected TableColumnModel columnModel
- The TableColumnModel of the table
selectionModel
protected ListSelectionModel selectionModel
- The ListSelectionModel of the table, used to keep track of row selections
tableHeader
protected JTableHeader tableHeader
- The TableHeader working with the table
rowHeight
protected int rowHeight
- The height of all rows in the table
rowMargin
protected int rowMargin
- The height margin between rows
gridColor
protected Color gridColor
- The color of the grid
showGrid
protected boolean showGrid
- The table draws a grid between cells if showGrid is true
multipleSelectionAllowed
protected boolean multipleSelectionAllowed
- Multiple rows selected allowed in this table
emptySelectionAllowed
protected boolean emptySelectionAllowed
- Empty selection allowed in this table
rowSelectionAllowed
protected boolean rowSelectionAllowed
- Row selection allowed in this table
simultaneousRowColumnSelectionAllowed
protected boolean simultaneousRowColumnSelectionAllowed
- If this is true, then both a row selection and a column selection
can be non-empty at the same time. Typically, when you select one
the other is deselected.
isRowSelected
protected boolean isRowSelected
cellEditor
protected TableCellEditor cellEditor
editingColumn
protected int editingColumn
editingRow
protected int editingRow
JTable
public JTable()
JTable
public JTable(TableDataModel dm)
JTable
public JTable(TableDataModel dm,
TableColumnModel cm)
setTableHeader
public void setTableHeader(JTableHeader newHeader)
- Sets the tableHeader working with this JTable to newHeader.
It is legal to have a null tableHeader.
- Parameters:
- newHeader - new tableHeader
- See Also:
- getTableHeader
getTableHeader
public JTableHeader getTableHeader()
- Returns the tableHeader working with this JTable.
- Returns:
- the tableHeader working with the receiver
- See Also:
- setTableHeader
setRowHeight
public void setRowHeight(int newHeight)
- Sets the height for rows to newRowHeight and invokes tile
- Parameters:
- newRowHeight - new row height
- Throws: IllegalArgumentException
- If newRowHeight is less
than 1.
- See Also:
- getRowHeight
getRowHeight
public int getRowHeight()
- Returns the height of a table row in the receiver.
The default row height is 16.0.
- Returns:
- the height of each row in the receiver
- See Also:
- setRowHeight
setIntercellSpacing
public void setIntercellSpacing(Dimension newSpacing)
- Sets the width and height between cells to newSpacing and
redisplays the receiver.
- Parameters:
- newSpacing - The new width and height intercellSpacing
- See Also:
- getIntercellSpacing
getIntercellSpacing
public Dimension getIntercellSpacing()
- Returns the horizontal and vertical spacing between cells.
The default spacing is (3, 2).
- Returns:
- the horizontal and vertical spacing between cells
- See Also:
- setIntercellSpacing
setGridColor
public void setGridColor(Color newColor)
- Sets the color used to draw grid lines to color and redisplays
the receiver.
The default color is gray.
- Parameters:
- color - new color of the grid
- Throws: IllegalArgumentException
- if color is null
- See Also:
- getGridColor
getGridColor
public Color getGridColor()
- Returns the color used to draw grid lines. The default color is gray.
- Returns:
- the color used to draw grid lines
- See Also:
- setGridColor
setShowGrid
public void setShowGrid(boolean b)
- Sets whether the receiver draws grid lines around cells.
If flag is true it does; if it is false it doesn't.
- Parameters:
- flag - true if table view should draw grid
lines
- See Also:
- getShowGrid
getShowGrid
public boolean getShowGrid()
- Returns true if the receiver draws grid lines around cells, false if it
doesn't. The default is true.
- Returns:
- true if the receiver draws grid lines around cells, false if it
doesn't
- See Also:
- setShowGrid
setMultipleSelectionAllowed
public void setMultipleSelectionAllowed(boolean flag)
- Sets whether the user can select more than one column or row at a time.
- See Also:
- getMultipleSelectionAllowed
getMultipleSelectionAllowed
public boolean getMultipleSelectionAllowed()
- Returns:
- true if the receiver allows more than one column or row selected
- See Also:
- setMultipleSelectionAllowed
setEmptySelectionAllowed
public void setEmptySelectionAllowed(boolean flag)
- Sets whether the user can select zero columns or rows.
- See Also:
- getEmptySelectionAllowed
getEmptySelectionAllowed
public boolean getEmptySelectionAllowed()
- Returns:
- true if the receiver allows zero column or rows selected
- See Also:
- setEmptySelectionAllowed
setRowSelectionAllowed
public void setRowSelectionAllowed(boolean flag)
- Sets whether the rows in this model can be selected.
- See Also:
- getRowSelectionAllowed
getRowSelectionAllowed
public boolean getRowSelectionAllowed()
- Returns:
- true if rows can be selected.
- See Also:
- setRowSelectionAllowed
setColumnSelectionAllowed
public void setColumnSelectionAllowed(boolean flag)
- Sets whether the columns in this model can be selected.
- See Also:
- getColumnSelectionAllowed
getColumnSelectionAllowed
public boolean getColumnSelectionAllowed()
- Returns:
- true if columns can be selected.
- See Also:
- setColumnSelectionAllowed
setSimultaneousRowColumnSelectionAllowed
public void setSimultaneousRowColumnSelectionAllowed(boolean flag)
- Sets whether this table allows both a column selection and a
row selection to exist at the same time. The default is false,
which means, when the user selects a column all rows are deselected,
and vice versa.
- See Also:
- getSimultaneousRowColumnSelectionAllowed
getSimultaneousRowColumnSelectionAllowed
public boolean getSimultaneousRowColumnSelectionAllowed()
- Returns:
- true if simultaneous row and column selections are allowed
- See Also:
- setSimultaneousRowColumnSelectionAllowed
selectAll
public void selectAll()
- If a column is selected, then this selects all columns. Similarly,
if a row is selected, then, this selects all rows. If both a column
and a row are selected at the time this method is invoked, then
all columns and rows are selected.
clearSelection
public void clearSelection()
- Deselects all selected columns and rows. If empty selection is not
allowed, then it leaves the first row selected.
setRowSelectionInterval
public void setRowSelectionInterval(int index0,
int index1)
- Selects the rows from index0 to index1 inclusive,
if row selection is allowed. If multiple selection is not
allowed then it only selects the row at index0.
- Parameters:
- index0 - one end of the interval.
- index1 - other end of the interval
setColumnSelectionInterval
public void setColumnSelectionInterval(int index0,
int index1)
- Selects the columns from index0 to index1 inclusive,
if column selection is allowed. If multiple selection is not
allowed then it only selects the column at index0.
- Parameters:
- index0 - one end of the interval.
- index1 - other end of the interval
addRowSelectionInterval
public void addRowSelectionInterval(int index0,
int index1)
- Adds the rows from index0 to index0 inclusive to
the current selection, if row selection and multiple selection
is allowed.
- Parameters:
- index0 - one end of the interval.
- index1 - other end of the interval
addColumnSelectionInterval
public void addColumnSelectionInterval(int index0,
int index1)
- Adds the columns from index0 to index0 inclusive to
the current selection, if column selection and multiple selection
is allowed.
- Parameters:
- index0 - one end of the interval.
- index1 - other end of the interval
removeRowSelectionInterval
public void removeRowSelectionInterval(int index0,
int index1)
- Deselects the rows from index0 to index0 inclusive.
If empty selection is not allowed then this might leave one row
selected.
- Parameters:
- index0 - one end of the interval.
- index1 - other end of the interval
removeColumnSelectionInterval
public void removeColumnSelectionInterval(int index0,
int index1)
- Deselects the columns from index0 to index0 inclusive.
If empty selection is not allowed then this might leave one column
selected.
- Parameters:
- index0 - one end of the interval.
- index1 - other end of the interval
getSelectedRow
public int getSelectedRow()
- Returns:
- the index of the last row selected or added to the selection,
(lead selection) or -1 if no row is selected.
- See Also:
- getSelectedRows
getSelectedColumn
public int getSelectedColumn()
- Returns:
- the index of the last column selected or added to the selection,
(lead selection) or -1 if no column is selected.
- See Also:
- getSelectedColumns
getSelectedRows
public int[] getSelectedRows()
- Returns:
- the indices of all selected rows, or an empty int array if
no row is selected.
- See Also:
- getSelectedRow
getSelectedColumns
public int[] getSelectedColumns()
- Returns:
- the indices of all selected columns, or an empty int array if
no column is selected.
- See Also:
- getSelectedColumn
getSelectedRowCount
public int getSelectedRowCount()
- Returns:
- the number of selected rows. 0 if no columns are selected.
getSelectedColumnCount
public int getSelectedColumnCount()
- Returns:
- the number of selected columns. 0 if no columns are selected.
isRowSelected
public boolean isRowSelected(int row)
- Returns:
- true if the row at index row is selected
- Throws: IllegalArgumentException
- if row is not in the
valid range
isColumnSelected
public boolean isColumnSelected(int column)
- Returns:
- true if the column at index column is selected
- Throws: IllegalArgumentException
- if column is not in the
valid range
isColumnSelected
public boolean isColumnSelected(Object identifier)
- Returns:
- true if the column with an identifier matching identifer
is selected
getColumnCount
public int getColumnCount()
- Returns the number of columns in the table
- Returns:
- the number of columns in the table
getRowCount
public int getRowCount()
- Returns the number of rows in the table.
addColumn
public void addColumn(JTableColumn c)
- Appends aColumn to the end of the JTable's array of columns.
- Parameters:
- column - The JTableColumn to be added
columnAtPoint
public int columnAtPoint(Point point)
- Returns the index of the column that point lies in, or -1 if it
lies outside the receiver's bounds.
- Returns:
- the index of the column that point lies in, or -1 if it
lies outside the receiver's bounds
- See Also:
- rowAtPoint
rowAtPoint
public int rowAtPoint(Point point)
- Returns the index of the row that point lies in, or -1 if it lies
outside the receiver's bounds.
- Returns:
- the index of the row that point lies in, or -1 if it
lies outside the receiver's bounds
- See Also:
- columnAtPoint
getCellRect
public Rectangle getCellRect(int column,
int row,
boolean includeSpacing)
- Returns a rectangle locating the cell that lies at the intersection of
column and row. If includeSpacing is true then
the value returned includes the intercellSpacing margin. If it is false,
then the returned rect is inset by half of intercellSpacing.
(This is the true frame of the cell)
- Parameters:
- column - the column to compute
- row - the row to compute
- includeSpacing - if true, the rect returned will
include the correct
intercellSpacing
- Returns:
- the rectangle containing the cell at index
column,row
- Throws: IllegalArgumentException
- If column or row
are not in the valid range.
editColumnRow
public boolean editColumnRow(int column,
int row)
- Programmatically starts editing the cell at column and row,
if the cell is editable.
- Parameters:
- column - the index of column to be
edited
- row - the index of row to be edited
- Returns:
- false if for any reason the cell cannot be edited.
- Throws: IllegalArgumentException
- If column or row
are not in the valid range
isEditing
public boolean isEditing()
- Returns:
- true is the table is editing a cell
- See Also:
- editingColumn, editingRow
editingColumn
public int editingColumn()
- If sent while isEditing() is true, this returns the index of the
editing column; otherwise returns -1.
- Returns:
- the index of the column being edited; otherwise returns -1
- See Also:
- editingRow
editingRow
public int editingRow()
- If sent while isEditing() is true, this returns the index of the
editing row; otherwise returns -1.
- Returns:
- the index of the row being edited; otherwise returns -1
- See Also:
- editingColumn
setValueForEditingCell
public void setValueForEditingCell(Object value)
getUI
public TableUI getUI()
setUI
public void setUI(TableUI ui)
updateUI
public void updateUI()
- Called to replace the UI with the latest version from the
default UIFactory.
- Overrides:
- updateUI in class JComponent
setModel
public void setModel(TableDataModel newModel)
- Sets the data model for this table to newModel and registers
with for listner notifications from the new data model. If
newModel is null, this view is disconnected from its current
model, if it has one.
- Parameters:
- newModel - the new data source for this table
- See Also:
- getModel
getModel
public TableDataModel getModel()
- Returns the TableDataModel that provides the data displayed by
the receiver.
- Returns:
- the object that provides the data displayed by the receiver
- See Also:
- setModel
setColumnModel
public void setColumnModel(TableColumnModel newModel)
- Sets the column model for this table to newModel and registers
with for listner notifications from the new column model.
- Parameters:
- newModel - the new data source for this table
- Throws: IllegalArgumentException
- if newModel is null
- See Also:
- getColumnModel
getColumnModel
public TableColumnModel getColumnModel()
- Returns the TableColumnModel that contains all column inforamtion
of this table.
- Returns:
- the object that provides the column state of the table
- See Also:
- setColumnModel
setSelectionModel
public void setSelectionModel(ListSelectionModel newModel)
- Sets the row selection model for this table to newModel
and registers with for listner notifications from the new selection model.
If newModel is null, it means the rows in this table are not
selectable.
- Parameters:
- newModel - the new selection model
- See Also:
- getSelectionModel
getSelectionModel
public ListSelectionModel getSelectionModel()
- Returns the ListSelectionModel that is used to maintain row
selection state.
- Returns:
- the object that provides row selection state. Or null
if row selection is not allowed.
- See Also:
- setSelectionModel
tableCellChanged
public void tableCellChanged(TableModelEvent e)
tableRowsChanged
public void tableRowsChanged(TableModelEvent e)
tableRowsInserted
public void tableRowsInserted(TableModelEvent e)
tableRowsRemoved
public void tableRowsRemoved(TableModelEvent e)
tableChanged
public void tableChanged(TableModelEvent e)
columnAdded
public void columnAdded(TableColumnModelEvent e)
columnRemoved
public void columnRemoved(TableColumnModelEvent e)
columnMoved
public void columnMoved(TableColumnModelEvent e)
columnMarginChanged
public void columnMarginChanged(ChangeEvent e)
columnSelectionChanged
public void columnSelectionChanged(ListSelectionEvent e)
valueChanged
public void valueChanged(ListSelectionEvent e)
initializeLocalVars
protected void initializeLocalVars()
createDefaultDataModel
protected TableDataModel createDefaultDataModel()
createDefaultColumnModel
protected TableColumnModel createDefaultColumnModel()
createDefaultSelectionModel
protected ListSelectionModel createDefaultSelectionModel()
createDefaultTableHeader
protected JTableHeader createDefaultTableHeader()
resizeAndRepaint
protected void resizeAndRepaint()
- Properly sizes the receiver and its header view, and marks it as
needing display. Also resets cursor rectangles for the header view
and line scroll amounts for the JScrollPane.
getCellEditor
public TableCellEditor getCellEditor()
- Set the cellEditor variable
setCellEditor
public void setCellEditor(TableCellEditor anEditor)
- Set the cellEditor variable
setEditingColumn
public void setEditingColumn(int aColumn)
- Set the editingColumn variable
setEditingRow
public void setEditingRow(int aRow)
- Set the editingRow variable
isOpaque
public boolean isOpaque()
- Overrides:
- isOpaque in class JComponent
All Packages Class Hierarchy This Package Previous Next Index