Paging table

May be who knows how make table with paging?
Example: i have 100 rows in dataset. I need display in table only 20 rows. And using buttons to switch next page with 20 rows


You would do something like this:

from javax.swing import SwingUtilities
from javax.swing import JScrollPane

rows = 21
table = event.source.parent.getComponent(‘Table’)
height = table.getRowHeight()*(rows-1)

scrollPane = SwingUtilities.getAncestorOfClass(JScrollPane, event.source.parent.getComponent(‘Table’).getComponents()[1])
scrollBar = scrollPane.getVerticalScrollBar()
scrollBar.setValue(scrollBar.getValue()+ height)[/code]

The code above, placed in a button’s actionPerformed script, will scroll the table down to display the next 20 rows in the dataset.
You can use similar logic for scrolling up, etc.
The code implies that the table height is set to show only 20 rows at a time.