public class StringArrayTableModel extends Object implements TableModel
A table model that gets its data from a String
array.
TableModel.TableModelEvent
Constructor and Description |
---|
StringArrayTableModel(int columns,
String... colnames)
Create a new table cell model with the given data.
|
Modifier and Type | Method and Description |
---|---|
void |
addRow(String... values) |
void |
addTableModelListener(ActionListener<TableModel.TableModelEvent> l)
Add a listener to be notified of changes to the model.
|
void |
deleteRow(int row) |
ContentType |
getCellContentType(int row,
int column)
Get the content type of a cell.
|
int |
getColumnCount()
Get the number of columns in the model.
|
String |
getColumnName(int column)
Get the name of the given column
|
int |
getRowCount()
Get the number of rows in the model.
|
Object |
getValueAt(int rowIndex,
int columnIndex)
Get the value of a particular cell.
|
void |
insertRow(int rowNum,
String... values) |
boolean |
isCellEditable(int rowIndex,
int columnIndex)
Check if the cell is editable.
|
void |
removeTableModelListener(ActionListener<TableModel.TableModelEvent> l)
Remove a listener.
|
void |
setValueAt(Object value,
int rowIndex,
int columnIndex)
Set the value in a cell.
|
public StringArrayTableModel(int columns, String... colnames)
Create a new table cell model with the given data.
columns
- The number of columnscolnames
- The cell data. The first columns values are interpreted as the column names, and the rest is row data.public ContentType getCellContentType(int row, int column)
TableModel
Get the content type of a cell.
getCellContentType
in interface TableModel
row
- The row.column
- The columnpublic int getColumnCount()
TableModel
Get the number of columns in the model.
getColumnCount
in interface TableModel
public String getColumnName(int column)
TableModel
Get the name of the given column
getColumnName
in interface TableModel
column
- The column numberpublic int getRowCount()
TableModel
Get the number of rows in the model.
getRowCount
in interface TableModel
public Object getValueAt(int rowIndex, int columnIndex)
TableModel
Get the value of a particular cell.
getValueAt
in interface TableModel
rowIndex
- The row of the cellcolumnIndex
- The column of the cellpublic boolean isCellEditable(int rowIndex, int columnIndex)
TableModel
Check if the cell is editable.
isCellEditable
in interface TableModel
rowIndex
- The rowcolumnIndex
- The columnpublic void setValueAt(Object value, int rowIndex, int columnIndex)
TableModel
Set the value in a cell.
setValueAt
in interface TableModel
value
- The value to set.rowIndex
- The rowcolumnIndex
- The columnpublic void addTableModelListener(ActionListener<TableModel.TableModelEvent> l)
TableModel
Add a listener to be notified of changes to the model.
addTableModelListener
in interface TableModel
public void removeTableModelListener(ActionListener<TableModel.TableModelEvent> l)
TableModel
Remove a listener.
removeTableModelListener
in interface TableModel
public void insertRow(int rowNum, String... values)
public void addRow(String... values)
public void deleteRow(int row)
Copyright © 2022. All Rights Reserved.