Java Reference
In-Depth Information
Table 16.1 AbstractTableModel methods for data change notification
Method
When to use
Use when only a single cell has
changed.
fireTableCellUpdated(int row, int col)
Use when the given range of rows
(inclusive) have changed.
fireTableRowsUpdated(int first, int last)
Use when the given range of rows
(inclusive) have been deleted.
fireTableRowsDeleted(int first, int last)
Use when the given range of rows
(inclusive) have been inserted.
fireTableRowsInserted(int first, int last)
Use when any/all of the row data
have changed, including the
number of rows; columns have
not changed.
fireTableDataChanged()
Use when the columns have
changed—that is, when the
names, number, or types of
columns have changed.
fireTableStructureChanged()
An all purpose method, where
you have to define the change in
the TableModelEvent object.
fireTableChanged(TableModelEvent e)
table.getTableHeader().setResizingAllowed(false);
table.getTableHeader().setReorderingAllowed(false);
The call is not made on the table directly, but rather on its header. We get
the JTableHeader object with the call to getTableHeader() . There is much
more that could be said about JTableHeader objects, but we will leave that
“as an exercise for the reader”; we've got to draw the line somewhere.
16.7.2.12
One last thing to mention about the createList() method is how we deal
with tables that are larger than the viewing area. This is typically done with a
scroll pane , a GUI element familiar to anyone who has used a word processing
program. Such scrolling is accomplished in Swing by putting the potentially
big object, such as our table, into a JScrollPane container.
Scrolling
Search WWH ::




Custom Search