public class ListTableModel extends AbstractTableModel
Modifier and Type | Field and Description |
---|---|
protected List |
dataList |
protected List |
headerList |
listenerList
Constructor and Description |
---|
ListTableModel()
Constructs a table model with zero rows and columns.
|
ListTableModel(List data)
Constructs a table model and initializes the data to the given
data list.
|
ListTableModel(List data,
List headers)
Constructs a table model and initializes the data to the given
data list and the headers to the given header list.
|
Modifier and Type | Method and Description |
---|---|
void |
addColumn(Object newCol)
Add a column to the model.
|
void |
addRow(int row,
List rowData)
Insert the given row to at the specified location in the model.
|
void |
addRow(List rowData)
Add the given row to the end of the model.
|
void |
addRowBatch(List rowData)
Add the given batch of rows to the end of the model.
|
Class |
getColumnClass(int col)
Used to determine the default renderer/editor for each cell.
|
int |
getColumnCount()
Returns the number of columns in the model.
|
String |
getColumnName(int col)
Returns the column name from the given column.
|
List |
getDataAt(int row)
Returns a list of data at the given row.
|
List |
getDataList()
Returns a List of Lists that contains the data for the table.
|
int |
getRowCount()
Returns the number of rows in the model.
|
Object |
getValueAt(int row,
int col)
Returns a value for the cell at the given row and column.
|
boolean |
isCellEditable(int row,
int col) |
void |
removeRow(int row)
Remove the given row from the model.
|
void |
setDataList(List data)
Replace the current data list with the given list.
|
void |
setHeaderList(List headers)
Replace the current header list with the given list.
|
void |
setValueAt(Object val,
int row,
int col)
Sets the value for the cell at the given row and column.
|
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener
public ListTableModel()
public ListTableModel(List data)
data
- the data for the modelpublic boolean isCellEditable(int row, int col)
isCellEditable
in interface TableModel
isCellEditable
in class AbstractTableModel
public int getRowCount()
public int getColumnCount()
public String getColumnName(int col)
getColumnName
in interface TableModel
getColumnName
in class AbstractTableModel
col
- the column whose name is to be looked uppublic Object getValueAt(int row, int col)
row
- the row whose value is to be looked upcol
- the column whose value is to be looked uppublic List getDataAt(int row)
row
- the row whose dat is to be looked uppublic List getDataList()
public void setValueAt(Object val, int row, int col)
setValueAt
in interface TableModel
setValueAt
in class AbstractTableModel
val
- the new value for the given cellrow
- the row whose value is to be changedcol
- the column whose value is to be changedpublic Class getColumnClass(int col)
getColumnClass
in interface TableModel
getColumnClass
in class AbstractTableModel
public void setDataList(List data)
data
- the new data listpublic void setHeaderList(List headers)
headers
- the new header listpublic void addColumn(Object newCol)
public void addRow(List rowData)
rowData
- the row being addedpublic void addRow(int row, List rowData)
row
- the index where the row is to be insertedrowData
- the row being addedpublic void addRowBatch(List rowData)
rowData
- mutliple rows of datapublic void removeRow(int row)
row
- the index of the row to be removedCopyright © 2003, 2023, Oracle and/or its affiliates.