Package smile.swing.table
Class PageTableModel
java.lang.Object
javax.swing.table.AbstractTableModel
smile.swing.table.PageTableModel
- All Implemented Interfaces:
Serializable
,TableModel
A table model that performs "paging" of its data. This model
reports a small number of rows (like 100 or so) as a "page" of data. You
can switch pages to view all the rows as needed using the pageDown()
and pageUp() methods. Presumably, access to the other pages of data is
dictated by other GUI elements such as up/down buttons, or maybe a text
field that allows you to enter the page number you want to display.
- See Also:
-
Field Summary
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
getPage()
Returns the current page.int
Returns the number of pages.int
Returns the page size.int
getRealRow
(int row) Returns the row number of data given the row number of current page.abstract int
The subclass should implement this method to return the real number of rows in the model.int
Returns a toolbar to control the plot.getValueAt
(int row, int col) abstract Object
getValueAtRealRow
(int row, int col) Returns the value for the cell at real row index.boolean
pageDown()
Moves to next page and fire a data changed (all rows).boolean
pageUp()
Moves to previous page and fire a data changed (all rows).boolean
setPage
(int p) Moves to specific page and fire a data changed (all rows).void
setPageSize
(int s) Sets the page size.Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getColumnName, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener, setValueAt
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface javax.swing.table.TableModel
getColumnCount
-
Constructor Details
-
PageTableModel
public PageTableModel()Default constructor. -
PageTableModel
public PageTableModel(int pageSize) Constructor.- Parameters:
pageSize
- The number of rows per page.
-
-
Method Details
-
getRowCount
public int getRowCount() -
getRealRowCount
public abstract int getRealRowCount()The subclass should implement this method to return the real number of rows in the model.- Returns:
- The real number of rows in the model.
-
getRealRow
public int getRealRow(int row) Returns the row number of data given the row number of current page.- Parameters:
row
- the row number in the current page.- Returns:
- the row number in the whole date set.
-
getValueAt
-
getValueAtRealRow
Returns the value for the cell at real row index.- Parameters:
row
- the real row whose value is to be queried.col
- the column whose value is to be queried.- Returns:
- the value Object at the specified cell
-
getPage
public int getPage()Returns the current page.- Returns:
- the current page.
-
setPage
public boolean setPage(int p) Moves to specific page and fire a data changed (all rows).- Returns:
- true if we can move to the page.
-
getPageCount
public int getPageCount()Returns the number of pages.- Returns:
- the number of pages.
-
getPageSize
public int getPageSize()Returns the page size.- Returns:
- the page size.
-
setPageSize
public void setPageSize(int s) Sets the page size.- Parameters:
s
- the page size.
-
pageDown
public boolean pageDown()Moves to next page and fire a data changed (all rows).- Returns:
- true if we can move to next page.
-
pageUp
public boolean pageUp()Moves to previous page and fire a data changed (all rows).- Returns:
- true if we can move to previous page.
-
getToolbar
Returns a toolbar to control the plot.- Returns:
- a toolbar to control the plot.
-