I have a client screen display a big list data in a JTable. The client is Swing application. It requests the data from a remote server. The list data need to be displayed in scrollable pagination mode. That means the rows should be requested only when user scroll the table (like the way Oracle Developer displays the queried data). So is the any good practice to follow? My 2 main concerning aspects are data requesting method (e.g. slice query, id caching...) and GUI handling.
Asked
Active
Viewed 493 times
1 Answers
1
SwingWorker is ideal for this, as it allows the query to continue in the background while the GUI is continually updated. Because JTable
uses the flyweight pattern to render cells, performance—even for thousands of rows—is usually acceptable. Here's an example.
Addendum: If you find that you want to enhance pagination, consider using RowFilter
, as suggested here, or simple controls, as shown here.
-
@mKorbel: I always welcome your insights. I hadn't looked at `ChristmasTree` in a while; very apropos. – trashgod Jul 09 '11 at 08:43
-
@mKorbel and the xmas tree example it related to the OPs problem in that ... ? the xmas is an exercise to increase the _rendering_ performance (not overly successful, as even the author Scott admitted: many hacks, little gain, mainly because there isn't much to improve to start with ;) – kleopatra Jul 09 '11 at 10:39
-
@kleopatra painting in visible ViewPort, and if changed, then invoke action ..., or I'm wrong? where... – mKorbel Jul 09 '11 at 10:49
-
@mKorbel interpreting your sentence as a loose description of the "pagination" requirement - again (stubborn me ;-) and that is related to the xmas tree article because ...? – kleopatra Jul 09 '11 at 13:03
-
one Swing/Java guru who not survived owners changes for sun and java.net .... (Jtable, Jtree, TreeTable and Nimbus) – mKorbel Jul 10 '11 at 08:53
-
Thanks for the explanation on JTable. However, the other interesting issue is how to make scrolling as smooth as possible. – Loc Phan Jul 14 '11 at 09:42
-
The best leverage, especially on dual-core machines, is to fetch rows in the background and let `JTable` & `JScrollPane` optimize the foreground. – trashgod Jul 14 '11 at 16:02