问题
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.
回答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.
来源:https://stackoverflow.com/questions/6632829/scrollable-pagination-client-servers