| java.lang.Object org.netbeans.microedition.lcdui.SimpleTableModel
SimpleTableModel | public class SimpleTableModel implements TableModel(Code) | | Simple implementation of TableModel. This model can hold a matrix of String
values. A matrix means all rows have to have the same number of columns
and rows cannot be null.
author: breh |
Constructor Summary | |
public | SimpleTableModel(String[][] values, String[] columnNames) Creates a model with given values and column names.
Parameters: values - values to be used in this table model. | public | SimpleTableModel(int rows, int cols) Creates a model with given number of rows and columns.
Parameters: rows - number of rows to be used in the model. | public | SimpleTableModel() Creates a new empty table model. |
SimpleTableModel | public SimpleTableModel(String[][] values, String[] columnNames) throws IllegalArgumentException(Code) | | Creates a model with given values and column names.
Parameters: values - values to be used in this table model. Please note, the values cannot be nulland have to be a valid matrix. Parameters: columnNames - column names to be used. Can be null if the column names are not goingto be used (see @isUsingHeaders method). throws: java.lang.IllegalArgumentException - If the values parameter is null, or if it is not a valid rectangular matrix. |
SimpleTableModel | public SimpleTableModel(int rows, int cols) throws IllegalArgumentException(Code) | | Creates a model with given number of rows and columns.
Parameters: rows - number of rows to be used in the model. Cannot be negative. Parameters: cols - number of columns to be used in the model. Cannot be negative. throws: java.lang.IllegalArgumentException - if the cols or rows argument are lower than zero |
SimpleTableModel | public SimpleTableModel()(Code) | | Creates a new empty table model.
|
addTableModelListener | public synchronized void addTableModelListener(TableModelListener listener)(Code) | | Adds a TableModelListener to this instance of the model.
Parameters: listener - listener to be addded |
fireTableModelChanged | public void fireTableModelChanged()(Code) | | Fires an event that the values in the table has been changed and
the table should be repainted. This method is intended to be used by
the user, since the model cannot track changes of
values in the supplied arrays.
|
getColumnCount | public int getColumnCount()(Code) | | Gets number of columns of the supplied values matrix.
values matrix column count |
getColumnName | public String getColumnName(int column)(Code) | | Gets the column name for the specified index
Parameters: column - column index column name |
getRowCount | public int getRowCount()(Code) | | Gets number of rows of the supplied values matrix.
values matrix row count |
getValue | public Object getValue(int col, int row)(Code) | | Gets the value of a table cell at a specified location. Always returns
String .
value for the given cell coordinates. May return null if there is no value. Parameters: col - col index of the value Parameters: row - row index of the value |
getValues | public String[][] getValues()(Code) | | Gets values of the model
values matrix |
isUsingHeaders | public boolean isUsingHeaders()(Code) | | Decides wheter this table is using headers (column names). This simple
model simply checks whether the supplied column names are null and in
such a case this method returns true.
true if the column names are being supplied and should be visualized, false otherwise |
removeTableModelListener | public synchronized void removeTableModelListener(TableModelListener listener)(Code) | | Removes a TableModelListener from this instance of the model.
Parameters: listener - listener to be removed |
setColumnNames | public void setColumnNames(String[] columnNames)(Code) | | Sets the column names for this model. The array of names
should have the same length as the column count.
Parameters: columnNames - array of names. May be null if the column headers should not be visualized |
setValue | public void setValue(int col, int row, String value) throws IllegalArgumentException(Code) | | Sets the value to the defined row and column of the model.
Please note, this method does not call fireTableModelChanged method
automatically, so you have to call it manually if you would like to redraw
the table. This is designed in this way, because of the performance reasons
- you might want to update several values at a time and repaint the
table at the end of the update.
throws: java.lang.IllegalArgumentException - if the values are not defined, or the specifed row or column is larger than the size of the values. |
setValues | public void setValues(String[][] values) throws IllegalArgumentException(Code) | | Sets the values of the model. Values of this model have to be a rectangular matrix -
this means all rows have to have the same number of columns and rows canot be null.
Please note, this class is holding just reference to the passed values array, so
any change you do to the model via setValue method is actually made in the array.
Parameters: values - values to be used in this table model. Please note, the values cannot be nulland have to be a valid matrix. throws: java.lang.IllegalArgumentException - If the values parameter is null, or if it is not a valid rectangular matrix. |
|
|