Groovy Documentation

com.wordpress.tipsforjava.swing.table
[Java] Class ListTableModel

java.lang.Object
  javax.swing.table.AbstractTableModel
      com.wordpress.tipsforjava.swing.table.RowTableModel
          com.wordpress.tipsforjava.swing.table.ListTableModel

public class ListTableModel
extends RowTableModel

Authors:
Rob Camick
Darryl Burke


Field Summary
 
Fields inherited from class RowTableModel
columnClasses, columnNames, isColumnEditable, isModelEditable, modelData, rowClass
 
Constructor Summary
ListTableModel(int columns)

Constructs an empty ListTableModel with default column names for the specified number of columns.

ListTableModel(List columnNames)

Constructs an empty ListTableModel with customized column names.

ListTableModel(int rows, int columns)

Constructs a ListTableModel with the specified number of rows.

ListTableModel(List modelData, List columnNames)

Constructs a ListTableModel with initial data and customized column names.

 
Method Summary
void addRow(Object[] rowData)

Adds a row of data to the end of the model.

private List copyToList(Object[] rowData)

static ListTableModel createModelFromResultSet(ResultSet resultSet)

Create a ListTableModel given a specific ResultSet.

Object getValueAt(int row, int column)

Returns an attribute value for the cell at row and column.

void insertRow(int row, List rowData)

Insert a row of data at the row location in the model.

void insertRow(int row, Object[] rowData)

Insert a row of data at the row location in the model.

void insertRows(int row, List rowList)

Insert multiple rows of data at the row location in the model.

void insertRows(int row, Object[] rowArray)

Insert multiple rows of data at the row location in the model.

private void justifyRow(List rowData)

protected static List newList(int size)

Initialize the List with null values.

void setValueAt(Object value, int row, int column)

Sets the object value for the cell at column and row.

 
Methods inherited from class RowTableModel
addRow, formatColumnName, getColumnClass, getColumnCount, getColumnName, getRow, getRowCount, getRowsAsArray, getRowsAsList, insertRow, insertRows, insertRows, isCellEditable, moveRow, removeRowRange, removeRows, replaceRow, setColumnClass, setColumnEditable, setDataAndColumnNames, setModelEditable, setRowClass
 
Methods inherited from class AbstractTableModel
getListeners, getColumnName, getColumnClass, isCellEditable, setValueAt, addTableModelListener, removeTableModelListener, fireTableStructureChanged, fireTableChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableCellUpdated, findColumn, getTableModelListeners, fireTableDataChanged, wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll, getRowCount, getColumnCount, getValueAt
 

Constructor Detail

ListTableModel

public ListTableModel(int columns)
Constructs an empty ListTableModel with default column names for the specified number of columns.
Parameters:
columns - the number of columns the table holds


ListTableModel

public ListTableModel(List columnNames)
Constructs an empty ListTableModel with customized column names. The number of columns is determined bye the number of items in the columnNames List.
Parameters:
columnNames - List containing the names of the new columns


ListTableModel

public ListTableModel(int rows, int columns)
Constructs a ListTableModel with the specified number of rows. Default column names will be used for the specified number of columns.
Parameters:
rows the - number of initially empty rows to create
columns - the number of columns the table holds


ListTableModel

public ListTableModel(List modelData, List columnNames)
Constructs a ListTableModel with initial data and customized column names. Each item in the modelData List must also be a List Object containing items for each column of the row. Each column's name will be taken from the columnNames List and the number of colums is determined by thenumber of items in the columnNames List.
Parameters:
modelData - the data of the table
columnNames - List containing the names of the new columns


 
Method Detail

addRow

public void addRow(Object[] rowData)
Adds a row of data to the end of the model. Notification of the row being added will be generated.
Parameters:
rowData - data of the row being added


copyToList

private List copyToList(Object[] rowData)


createModelFromResultSet

public static ListTableModel createModelFromResultSet(ResultSet resultSet)
Create a ListTableModel given a specific ResultSet. The column names and class type will be retrieved from the ResultSetMetaData. The data is retrieved from each row found in the ResultSet. The class of
Throws:
SQLException when an SQL error is encountered
Parameters:
resultSet - ResultSet containing results of a database query
Returns:
a newly created ListTableModel


getValueAt

public Object getValueAt(int row, int column)
Returns an attribute value for the cell at row and column.
Throws:
IndexOutOfBoundsException if an invalid row or column was given
Parameters:
row the - row whose value is to be queried
column - the column whose value is to be queried
Returns:
the value Object at the specified cell


insertRow

de
	public
public void insertRow(int row, List rowData)
Insert a row of data at the row location in the model. Notification of the row being added will be generated.
Parameters:
row - row in the model where the data will be inserted
rowData - data of the row being added


insertRow

public void insertRow(int row, Object[] rowData)
Insert a row of data at the row location in the model. Notification of the row being added will be generated.
Parameters:
row - row in the model where the data will be inserted
rowData - data of the row being added


insertRows

de
	public
public void insertRows(int row, List rowList)
Insert multiple rows of data at the row location in the model. Notification of the row being added will be generated.
Parameters:
row - row in the model where the data will be inserted
rowList - each item in the list is a separate row of data


insertRows

public void insertRows(int row, Object[] rowArray)
Insert multiple rows of data at the row location in the model. Notification of the row being added will be generated.
Parameters:
row - row in the model where the data will be inserted
rowArray - each item in the Array is a separate row of data


justifyRow

ssWarnings("unchecked")
	private
private void justifyRow(List rowData)


newList

protected static List newList(int size)
Initialize the List with null values. This will set the size of the List and will prevent an IndexOutOfBoundsException when trying to access an Element in the List.
Parameters:
size - the number of Elements to add to the List


setValueAt

ssWarnings("unchecked")
	public
public void setValueAt(Object value, int row, int column)
Sets the object value for the cell at column and row. value is the new value. This method will generate a tableChanged notification.
Throws:
IndexOutOfBoundsException if an invalid row or column was given
Parameters:
value - the new value; this can be null
row - the row whose value is to be changed
column - the column whose value is to be changed


 

Groovy Documentation