ElegantJ Tables Java API Specification v1.1

com.elegantj.jfc.table
Class DefaultJFCTableModel

java.lang.Object
  extended byjavax.swing.table.AbstractTableModel
      extended byjavax.swing.table.DefaultTableModel
          extended bycom.elegantj.jfc.table.DefaultJFCTableModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel

public class DefaultJFCTableModel
extends javax.swing.table.DefaultTableModel

This is an implementation of TableModel that uses a Vector of Vectors to store the cell value objects.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.table.DefaultTableModel
columnIdentifiers, dataVector
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
DefaultJFCTableModel()
          Constructs a default DefaultJFCTableModel which is a table of zero columns and zero rows.
DefaultJFCTableModel(int rowCount, int columnCount)
          Constructs a DefaultJFCTableModel with rowCount and columnCount of null object values.
DefaultJFCTableModel(java.lang.Object[][] data, java.lang.Object[] columnNames)
          Constructs a DefaultJFCTableModel and initializes the table by passing data and columnNames to the setDataVector method.
DefaultJFCTableModel(java.lang.Object[] columnNames, int rowCount)
          Constructs a DefaultJFCTableModel with as many columns as there are elements in columnNames and rowCount of null object values.
DefaultJFCTableModel(java.util.Vector columnNames, int rowCount)
          Constructs a DefaultJFCTableModel with as many columns as there are elements in columnNames and rowCount of null object values.
DefaultJFCTableModel(java.util.Vector data, java.util.Vector columnNames)
          Constructs a DefaultJFCTableModel and initializes the table by passing data and columnNames to the setDataVector method.
 
Method Summary
 void addColumn(java.lang.Object columnName, java.util.Vector columnData)
          Adds a column to the model.
 java.lang.String getColumnName(int column)
          Returns the column name.
 java.util.EventListener[] getListeners(java.lang.Class listenerType)
          Returns an array of all the listeners of the given type that were added to this model.
 void insertColumn(int column, java.lang.Object columnName, java.util.Vector columnData)
          Inserts a column to the model at column index.
 void newRowsAdded(javax.swing.event.TableModelEvent e)
          Ensures that the new rows have the correct number of columns.
 void removeColumn(int column)
          Removes the column from the data model at specified index.
 void removeColumn(java.lang.String columnName)
          Removes the column columnName from the data model.
 void removeRows(int[] rows)
          Removes the rows at row indexes from the model.
 void setColumnCount(int columnCount)
          Sets the number of columns in the model.
 void setColumnIdentifiers(java.util.Vector newIdentifiers)
          Replaces the column identifiers in the model.
 void setDataVector(java.util.Vector dataVector)
          Replaces the current dataVector instance variable with the new Vector of rows, newData.
 void setRowCount(int rowCount)
          Sets the number of rows in the model.
 
Methods inherited from class javax.swing.table.DefaultTableModel
addColumn, addColumn, addRow, addRow, convertToVector, convertToVector, getColumnCount, getDataVector, getRowCount, getValueAt, insertRow, insertRow, isCellEditable, moveRow, newDataAvailable, removeRow, rowsRemoved, setColumnIdentifiers, setDataVector, setDataVector, setNumRows, setValueAt
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getTableModelListeners, removeTableModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultJFCTableModel

public DefaultJFCTableModel()
Constructs a default DefaultJFCTableModel which is a table of zero columns and zero rows.


DefaultJFCTableModel

public DefaultJFCTableModel(int rowCount,
                            int columnCount)
Constructs a DefaultJFCTableModel with rowCount and columnCount of null object values.

Parameters:
rowCount - the number of rows the table holds
columnCount - the number of columns the table holds

DefaultJFCTableModel

public DefaultJFCTableModel(java.util.Vector columnNames,
                            int rowCount)
Constructs a DefaultJFCTableModel with as many columns as there are elements in columnNames and rowCount of null object values. Each column's name will be taken from the columnNames vector.

Parameters:
columnNames - vector containing the names of the new columns; if this is null then the model has no columns
rowCount - the number of rows the table holds

DefaultJFCTableModel

public DefaultJFCTableModel(java.lang.Object[] columnNames,
                            int rowCount)
Constructs a DefaultJFCTableModel with as many columns as there are elements in columnNames and rowCount of null object values. Each column's name will be taken from the columnNames array.

Parameters:
columnNames - array containing the names of the new columns; if this is null then the model has no columns
rowCount - the number of rows the table holds

DefaultJFCTableModel

public DefaultJFCTableModel(java.util.Vector data,
                            java.util.Vector columnNames)
Constructs a DefaultJFCTableModel and initializes the table by passing data and columnNames to the setDataVector method.

Parameters:
data - the data of the table
columnNames - vector containing the names of the new columns

DefaultJFCTableModel

public DefaultJFCTableModel(java.lang.Object[][] data,
                            java.lang.Object[] columnNames)
Constructs a DefaultJFCTableModel and initializes the table by passing data and columnNames to the setDataVector method. The first index in the Object[][] array is the row index and the second is the column index.

Parameters:
data - the data of the table
columnNames - the names of the columns
See Also:
DefaultTableModel.getDataVector(), setDataVector(java.util.Vector)
Method Detail

setRowCount

public void setRowCount(int rowCount)
Sets the number of rows in the model. If the new size is greater than the current size, new rows are added to the end of the model If the new size is less than the current size, all rows at index rowCount and greater are discarded.

Parameters:
rowCount - the new number of rows in the model

setColumnCount

public void setColumnCount(int columnCount)
Sets the number of columns in the model. If the new size is greater than the current size, new columns are added to the end of the model with null cell values. If the new size is less than the current size, all columns at index columnCount and greater are discarded.

Parameters:
columnCount - the new number of columns in the model

setColumnIdentifiers

public void setColumnIdentifiers(java.util.Vector newIdentifiers)
Replaces the column identifiers in the model. If the number of newIdentifiers is greater than the current number of columns, new columns are added to the end of each row in the model. If the number of newIdentifiers is less than the current number of columns, all the extra columns at the end of a row are discarded.

Parameters:
newIdentifiers - vector of column identifiers. If null, set the model to zero columns

addColumn

public void addColumn(java.lang.Object columnName,
                      java.util.Vector columnData)
Adds a column to the model. The new column will have the identifier columnName. columnData is the optional vector of data for the column. If it is null the column is filled with null values. Otherwise, the new data will be added to model starting with the first element going to row 0, etc. This method will send a tableChanged notification message to all the listeners.

Parameters:
columnName - the identifier of the column being added
columnData - optional data of the column being added

removeColumn

public void removeColumn(int column)
Removes the column from the data model at specified index.

Parameters:
column - the column index to be removed

removeColumn

public void removeColumn(java.lang.String columnName)
Removes the column columnName from the data model.

Parameters:
columnName - the column name to be removed

insertColumn

public void insertColumn(int column,
                         java.lang.Object columnName,
                         java.util.Vector columnData)
Inserts a column to the model at column index. The new column will have the identifier columnName. columnData is the optional vector of data for the column. If it is null the column is filled with null values. Otherwise, the new data will be inserted to model starting with the first element going to row 0, etc. This method will send a tableChanged notification message to all the listeners.

Parameters:
columnName - the identifier of the column being added
columnData - optional data of the column being added

getColumnName

public java.lang.String getColumnName(int column)
Returns the column name.

Returns:
a name for this column using the string value of the appropriate member in columnIdentifiers. If columnIdentifiers does not have an entry for this index, returns the default name provided by the superclass

setDataVector

public void setDataVector(java.util.Vector dataVector)
Replaces the current dataVector instance variable with the new Vector of rows, newData. columnNames are the names of the new columns. The first name in columnNames is mapped to column 0 in newData. Each row in newData is adjusted to match the number of columns in columnNames either by truncating the Vector if it is too long, or adding null values if it is too short.


newRowsAdded

public void newRowsAdded(javax.swing.event.TableModelEvent e)
Ensures that the new rows have the correct number of columns. This is accomplished by using the setSize method in Vector which truncates vectors which are too long, and appends nulls if they are too short. This method also sends out a tableChanged notification message to all the listeners.


removeRows

public void removeRows(int[] rows)
Removes the rows at row indexes from the model. Notification of the row being removed will be sent to all the listeners.

Parameters:
rows - the row indexes of the rows to be removed
Throws:
java.lang.ArrayIndexOutOfBoundsException - if the row indexes was invalid

getListeners

public java.util.EventListener[] getListeners(java.lang.Class listenerType)
Returns an array of all the listeners of the given type that were added to this model.


ElegantJ Tables Java API Specification v1.1

Submit a bug or feature

Copyright(c)
Elegant Microweb Technologies Pvt. Ltd.
www.elegantmicroweb.com
www.elegantjbeans.com
All Rights Reserved.