When displaying tables with tens of thousands of rows (or more), it is imperative they quickly respond and display. One way to achieve this is by using a specialized TableModel that retrieves data from a server only when it is required, thereby minimizing data download. To further improve efficiency, row data can be retrieved in chunks of 50 rows and cached on the client side for future use. This article explains how to write such a distributed table and presents some of its advantages. (1,500 words; April 18, 2003)
By default, the Swing JTable component allows only one editor type per column. In most cases, all cells in a JTable column are of the same class and thus can be edited with the same editor type. However, occasionally you may want a single column to contain objects of different classes and a different editor for each class. One such example is a property page from Visual Basic or Delphi. This article shows you how to extend JTable to allow for more than one editor in a column. (700 words)
The JTable class offers rich functionality for grid-like data display. This Java tip addresses common display issues related to dynamically changing such things as scroll bars, column width, and row height. (900 words; September 14, 2001)
4. Enable copy and paste functionality between Swing's JTables and Excel
JTables and Excel charts are commonly used to display data in a grid or table. Often, the data that the user wishes to enter into a JTable already exists in Excel spreadsheets. The Excel format is used for export-import functionality by software other than Excel. Because of this, it is important that Java software also provide common clipboard functionality, like copy and paste, between JTables and Excel. This article shows how to enable Java programs to copy data from JTables into Excel using the system clipboard. Using the adapter class presented in this Java Tip, the ability to copy and paste information to and from your JTables and Excel can be added with only one line of code. Note that, since the system clipboard is not accessible to unsigned applets, this functionality will not be available to those Java programs. (850 words)