|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.swing.table.AbstractTableModel | +--gradeview.data.PeopleTableModel
A simple table model to keep track of people and their attributes. Everything is stored in a Vector table, whose items consists of HashMaps. These HashMaps keep track of a person's various attributes, such as name, e-mail address, and so on. For example, the following list of people:
Misc.buildHashMap(String)
method is used to build the necessary HashMap. This reduces the amount
of code needed to build the table's data.)
PeopleTableModel myModel = new AbstractPeopleTableModel();
myModel.add( Misc.buildHashMap( "name=David Ludwig,email=davidl@wpi.edu" );
myModel.add( Misc.buildHashMap( "name=James Abbatiello,email=abbeyj@wpi.edu" );
JTable myTable = new JTable( myModel );
Field Summary | |
protected java.util.Vector |
peopleList
|
Fields inherited from class javax.swing.table.AbstractTableModel |
listenerList |
Constructor Summary | |
PeopleTableModel()
Constructor. |
Method Summary | |
void |
add(java.util.HashMap newPerson)
Adds a new person to the table. |
void |
delete(int row)
Deletes one person/row from the table. |
void |
delete(int[] rows)
Deletes multiple people/rows from the table. |
int |
getColumnCount()
Gets the amount of columns in the table. |
java.lang.String |
getColumnName(int col)
Gets the title/name of a particular column. |
int |
getRowCount()
Gets the amount of rows in the table (which is equal to the number of people in the list. |
java.lang.Object |
getValueAt(int row,
int col)
Gets the value at the specified row and column. |
void |
read()
Reads in a list of people from the database. |
void |
write()
Writes the list of people to the database. |
Methods inherited from class javax.swing.table.AbstractTableModel |
addTableModelListener,
findColumn,
fireTableCellUpdated,
fireTableChanged,
fireTableDataChanged,
fireTableRowsDeleted,
fireTableRowsInserted,
fireTableRowsUpdated,
fireTableStructureChanged,
getColumnClass,
isCellEditable,
removeTableModelListener,
setValueAt |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
protected java.util.Vector peopleList
Constructor Detail |
public PeopleTableModel()
Method Detail |
public int getColumnCount()
public int getRowCount()
public java.lang.Object getValueAt(int row, int col)
row
- The row number (starting at 0 on the top of the table.)col
- The column index (starting at 0 on the left side of the table.)public java.lang.String getColumnName(int col)
col
- The number of the column (starting at 0 on the left side of
the table.public void add(java.util.HashMap newPerson)
newPerson
- The new person, represented as a HashMap. (See this
class' description for information on the HashMap's structure.)Misc.buildHashMap(String)
public void delete(int row)
row
- The row of the table to be deleted.public void delete(int[] rows)
rows
- The rows to be deleted, represented by the type int[] (an
array of ints.) IMPORTANT NOTE: The array must be sorted in
ascending order. For example, the following array is sorted correctly:
(0, 1, 3, 4, 6, 10)public void read()
public void write()
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |