|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.swing.table.AbstractTableModel
com.cleancode.swing.SimpleTable
public class SimpleTable
Provides a table model based on AbstractTableModel,
typically used with a JTable component.
This class provides support for updating individual cells or the entire table.
It also includes some diagnostic facilities; one may dump the entire table
on command, or on events firing. This class defaults to all cells editable,
but providing a JTableCellChecker allows selectivity over which
cells are editable.
JTable,
JTableMgr,
How to Use Tables,
Serialized Form| Field Summary | |
|---|---|
static String |
VERSION
Current version of this class. |
| Fields inherited from class javax.swing.table.AbstractTableModel |
|---|
listenerList |
| Constructor Summary | |
|---|---|
SimpleTable(String diagName)
Creates a new SimpleTable with a single column;
all cells are editable. |
|
SimpleTable(String diagName,
String[] columnNames)
Creates a new SimpleTable with all cells editable. |
|
SimpleTable(String diagName,
String[] columnNames,
boolean editable)
Creates a new SimpleTable with all cells editable or all
cells immutable. |
|
SimpleTable(String diagName,
String[] columnNames,
JTableCellChecker target)
Creates a new SimpleTable with a custom cell checker. |
|
| Method Summary | |
|---|---|
void |
addRow()
Adds an empty row to the current table. |
void |
addRow(Object[] row)
Adds the specified row to the current table. |
void |
copyTable(SimpleTable table)
Copies the specified table into the current table. |
void |
copyTable(SimpleTable table,
int startCol,
int colCount)
Copies the specified table into the current table, specifying the starting column number and the number of columns to copy. |
void |
deleteRow(int rowIndex)
Deletes the specified row from the current table. |
void |
emptyTable()
Empties the current table, resetting the number of rows to zero. |
void |
fillTable(Object[][] newData)
Fills the table with new data (discarding any previously assigned). |
Class<?> |
getColumnClass(int colIndex)
Method used by JTable to determine
the default renderer/editor for each cell. |
int |
getColumnCount()
Returns the number of columns in the model. |
String |
getColumnName(int colIndex)
Returns the name of the specified column. |
int |
getRowCount()
Returns the number of rows in the model. |
Object |
getValueAt(int rowIndex,
int colIndex)
Returns the value for the cell at the specified row and column indices. |
boolean |
isCellEditable(int rowIndex,
int colIndex)
JTable uses this method to determine whether
a cell may be edited. |
void |
setValueAt(Object value,
int rowIndex,
int colIndex)
Sets the value for the cell at the specified row and column indices. |
String |
toCondensedString()
Returns a short string representation of this table. |
String |
toString()
Returns a string representation of this table. |
| Methods inherited from class javax.swing.table.AbstractTableModel |
|---|
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String VERSION
| Constructor Detail |
|---|
public SimpleTable(String diagName,
String[] columnNames,
JTableCellChecker target)
SimpleTable with a custom cell checker.
diagName - display name of this table for diagnostic purposescolumnNames - display names of columnstarget - cell checker object which determines cell editability
public SimpleTable(String diagName,
String[] columnNames,
boolean editable)
SimpleTable with all cells editable or all
cells immutable.
diagName - display name of this table for diagnostic purposescolumnNames - display names of columnseditable - boolean indicating editable or not
public SimpleTable(String diagName,
String[] columnNames)
SimpleTable with all cells editable.
diagName - display name of this table for diagnostic purposescolumnNames - display names of columnspublic SimpleTable(String diagName)
SimpleTable with a single column;
all cells are editable.
diagName - display name of this table for diagnostic purposes| Method Detail |
|---|
public String toString()
toString in class Objectpublic String toCondensedString()
diagName,
the number of rows, and the number of columns. These data are separated
by commas and enclosed in braces.
public void fillTable(Object[][] newData)
newData - two-dimensional list of table datapublic void copyTable(SimpleTable table)
table - table to copy
public void copyTable(SimpleTable table,
int startCol,
int colCount)
table - table to copystartCol - starting column numbercolCount - number of columns to copypublic void emptyTable()
public void addRow(Object[] row)
row - list of items comprising one row of the tablepublic void addRow()
public void deleteRow(int rowIndex)
rowIndex - index of the row to deletepublic int getColumnCount()
getRowCount()public int getRowCount()
getColumnCount()public String getColumnName(int colIndex)
getColumnName in interface TableModelgetColumnName in class AbstractTableModelcolIndex - the index of the column
public Class<?> getColumnClass(int colIndex)
JTable to determine
the default renderer/editor for each cell.
getColumnClass in interface TableModelgetColumnClass in class AbstractTableModelcolIndex - the column whose value is to be queried
public boolean isCellEditable(int rowIndex,
int colIndex)
JTable uses this method to determine whether
a cell may be edited.
isCellEditable in interface TableModelisCellEditable in class AbstractTableModelrowIndex - row index of the cellcolIndex - column index of the cell
public Object getValueAt(int rowIndex,
int colIndex)
rowIndex - row index of the cellcolIndex - column index of the cell
setValueAt(java.lang.Object, int, int)
public void setValueAt(Object value,
int rowIndex,
int colIndex)
setValueAt in interface TableModelsetValueAt in class AbstractTableModelvalue - new value for the cellrowIndex - row index of the cellcolIndex - column index of the cellgetValueAt(int, int)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
| CleanCode Java Libraries | Copyright © 2001-2012 Michael Sorens - Revised 2012.12.10 |