13.07.2015 Views

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

16.7 Getting Down to Cases: Designing a GUI for BudgetPro369Table 16.1 AbstractTableModel methods for data change notificati<strong>on</strong>MethodfireTableCellUpdated(int row, int col)fireTableRowsUpdated(int first, int last)fireTableRowsDeleted(int first, int last)fireTableRowsInserted(int first, int last)fireTableDataChanged()fireTableStructureChanged()fireTableChanged(TableModelEvent e)When to useUse when <strong>on</strong>ly a single cell haschanged.Use when the given range of rows(inclusive) have changed.Use when the given range of rows(inclusive) have been deleted.Use when the given range of rows(inclusive) have been inserted.Use when any/all of the row datahave changed, including thenumber of rows; columns havenot changed.Use when the columns havechanged—that is, when thenames, number, or types ofcolumns have changed.An all purpose method, whereyou have to define the change inthe TableModelEvent object.table.getTableHeader().setResizingAllowed(false);table.getTableHeader().setReorderingAllowed(false);The call is not made <strong>on</strong> the table directly, but rather <strong>on</strong> its header. We getthe JTableHeader object with the call to getTableHeader(). There is muchmore 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 ScrollingOne last thing to menti<strong>on</strong> about the createList() method is how we dealwith tables that are larger than the viewing area. This is typically d<strong>on</strong>e with ascroll pane, a GUI element familiar to any<strong>on</strong>e who has used a word processingprogram. Such scrolling is accomplished in Swing by putting the potentiallybig object, such as our table, into a JScrollPane c<strong>on</strong>tainer.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!