|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.netbeans.microedition.lcdui.SimpleTableModel
public class SimpleTableModel
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.
Constructor Summary | |
---|---|
SimpleTableModel()
Creates a new empty table model. |
|
SimpleTableModel(int rows,
int cols)
Creates a model with given number of rows and columns. |
|
SimpleTableModel(java.lang.String[][] values,
java.lang.String[] columnNames)
Creates a model with given values and column names. |
Method Summary | |
---|---|
void |
addTableModelListener(TableModelListener listener)
Adds a TableModelListener to this instance of the model. |
void |
fireTableModelChanged()
Fires an event that the values in the table has been changed and the table should be repainted. |
int |
getColumnCount()
Gets number of columns of the supplied values matrix. |
java.lang.String |
getColumnName(int column)
Gets the column name for the specified index |
int |
getRowCount()
Gets number of rows of the supplied values matrix. |
java.lang.Object |
getValue(int col,
int row)
Gets the value of a table cell at a specified location. |
java.lang.String[][] |
getValues()
Gets values of the model |
boolean |
isUsingHeaders()
Decides wheter this table is using headers (column names). |
void |
removeTableModelListener(TableModelListener listener)
Removes a TableModelListener from this instance of the model. |
void |
setColumnNames(java.lang.String[] columnNames)
Sets the column names for this model. |
void |
setValue(int col,
int row,
java.lang.String value)
Sets the value to the defined row and column of the model. |
void |
setValues(java.lang.String[][] values)
Sets the values of the model. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SimpleTableModel(java.lang.String[][] values, java.lang.String[] columnNames) throws java.lang.IllegalArgumentException
values
- values to be used in this table model. Please note, the values cannot be null
and have to be a valid matrix.columnNames
- column names to be used. Can be null if the column names are not going
to be used (see @isUsingHeaders method).
java.lang.IllegalArgumentException
- If the values parameter is null, or if it is not a valid rectangular matrix.public SimpleTableModel(int rows, int cols) throws java.lang.IllegalArgumentException
rows
- number of rows to be used in the model. Cannot be negative.cols
- number of columns to be used in the model. Cannot be negative.
java.lang.IllegalArgumentException
- if the cols or rows argument are lower than zeropublic SimpleTableModel()
Method Detail |
---|
public int getColumnCount()
getColumnCount
in interface TableModel
public int getRowCount()
getRowCount
in interface TableModel
public void setValue(int col, int row, java.lang.String value) throws java.lang.IllegalArgumentException
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.
java.lang.IllegalArgumentException
- if the values are not defined, or
the specifed row or column is larger than the size of the values.public void setValues(java.lang.String[][] values) throws java.lang.IllegalArgumentException
values
- values to be used in this table model. Please note, the values cannot be null
and have to be a valid matrix.
java.lang.IllegalArgumentException
- If the values parameter is null, or if it is not a valid rectangular matrix.public java.lang.String[][] getValues()
public java.lang.Object getValue(int col, int row)
String
.
getValue
in interface TableModel
col
- col index of the valuerow
- row index of the value
public boolean isUsingHeaders()
isUsingHeaders
in interface TableModel
public void setColumnNames(java.lang.String[] columnNames)
columnNames
- array of names. May be null if the column headers should not be visualizedpublic java.lang.String getColumnName(int column)
getColumnName
in interface TableModel
column
- column index
public void fireTableModelChanged()
public void addTableModelListener(TableModelListener listener)
TableModelListener
to this instance of the model.
addTableModelListener
in interface TableModel
listener
- listener to be adddedpublic void removeTableModelListener(TableModelListener listener)
TableModelListener
from this instance of the model.
removeTableModelListener
in interface TableModel
listener
- listener to be removed
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |