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 AbstractTableModel
listenerList -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintgetPage()Returns the current page.intReturns the number of pages.intReturns the page size.intgetRealRow(int row) Returns the row number of data given the row number of current page.abstract intThe subclass should implement this method to return the real number of rows in the model.intReturns a toolbar to control the plot.getValueAt(int row, int col) abstract ObjectgetValueAtRealRow(int row, int col) Returns the value for the cell at real row index.booleanpageDown()Moves to next page and fire a data changed (all rows).booleanpageUp()Moves to previous page and fire a data changed (all rows).booleansetPage(int p) Moves to specific page and fire a data changed (all rows).voidsetPageSize(int s) Sets the page size.Methods inherited from class AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getColumnName, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener, setValueAtMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface 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).- Parameters:
p- the page number.- 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.
-