Class PageTableModel

java.lang.Object
javax.swing.table.AbstractTableModel
smile.swing.table.PageTableModel
All Implemented Interfaces:
Serializable, TableModel

public abstract class PageTableModel extends AbstractTableModel
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:
  • 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

      public Object getValueAt(int row, int col)
    • getValueAtRealRow

      public abstract Object getValueAtRealRow(int row, int col)
      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

      public JToolBar getToolbar()
      Returns a toolbar to control the plot.
      Returns:
      a toolbar to control the plot.