Chapter 12 Examples


 
Note
All of the examples were updated from the book to use the default font in the tables. All of the examples were also updated for Java 2 by replacing the deprecated createScrollPaneForTable method with the standard JScrollPane constructor.
 
Table Model
FileSystemTableModel.java defines a custom table model based on the file system. FileTable.java displays information about a directory based on the command line arguments.
 
Table Selection Modes
FileSystemTableModel.java defines a custom table model based on the file system. CellFileTable.java displays information about a directory based on the command line arguments, this table supports cell by cell selections.
 
Table Selection Listeners
FileSystemTableModel.java defines a custom table model based on the file system. SelTable.java displays information about a directory based on the command line arguments, a ListSelectionListener is used to receive notifications when the table's selection changes.
 
Editable Table Models
FileSystemTableModel.java defines an editable custom table model based on the file system. EditFileTable.java displays information about a directory based on the command line arguments, the table supports editing.
 
JDBC and Tables
JDBCTableModel.java defines an editable custom table model based on information in a database. JDBC is used to retreive the information. JDBCTable.java displays information from a database in a table. Note, you will need to update the JDBC connection information to run this example.

We updated the JDBCTableModel from the book to no longer say that the bit type is a boolean type. This is not true for all drivers. There was also a classic typo in the JDBCTableModel where the break statements are left out of a switch statement. These are fixed.
 
Table Mouse Listeners
FileSystemTableModel.java defines a custom table model based on the file system. TripleClicker.java defines a MouseListener that waits for triple clicks. ClickTable.java displays information about a directory based on the command line arguments, a TripleClicker is assigned as a mouse listener for the table. If you can't seem to get the triple click to be caught, try clicking the mouse 4 times to make sure that the events are being captured.


Copyright � 1998, John Wiley and Sons, Inc.