Recommended: Sing it, brah! 5 fabulous songs for developers
JW's Top 5
Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
Page 3 of 3
int[] sort(int sortColumn, boolean ascending, int[] selectedRows) throws Exception
Along with the sort column and ascending flag, you must feed in the selected row indexes and then return the sorted data's
corresponding indexes. Three more methods are required to implement sorting fully: setSelectedRowsAndColumns(), getSelectedRows(), and getSelectedColumns(). These methods keep the selections in sync between the client and server.
Figure 3 shows a sequence diagram for the sorting and selection process.
Figure 3. A sequence diagram shows a distributed JTable's sorting process. Click on thumbnail to view full-size image.
I've described a method that allows a large table to quickly display without waiting for a bulk data download. If a user scrolls down the whole table, all the data must download sooner or later. But there is always a balance between immediately downloading all data and taking the performance hit later. This tip's method provides the following advantages:
The associated source code provides this process's proof-of-concept implementation. In that demo, a client containing a read-only
sortable JTable of 200,000 rows retrieves data from a servlet as XML and stores it in a DistributedTableModel. You can easily extend this demo to implement single cell selection, data editing, and more.
Read more about Core Java in JavaWorld's Core Java section.