Displaying results as "pages" of a JTable and sorting across all results ...

Discussion in 'Java' started by Monique Y. Mudama, Jun 27, 2005.

  1. Hi all ...

    I've recently returned to the world of Java after an extended
    sabbatical, but I'll admit that my grasp of TableModels and such was
    never all that great.

    So now I have a JTable question ... and it seems like such a common
    need that there must be an obvious, known solution ...

    I need to display a lot of results, one "page" at a time. I imagine a
    JTable which is repopulated when the user clicks on a "Next" button.
    On the face of it, that part seems pretty easy. I already have a
    JTable that's repopulated based on new search terms.

    Now, the result set in this case may be huge -- I simply can't request
    the entire set of data at once. I can, however, query for results x
    through y of the full set, and I can request the total number of hits.
    Populating the TableModel and calling fireTableDataChanged(), again,
    not a problem.

    Here's the problem. I need the table to be sortable such that if the
    user requests a change in the sort order of a column, the sort will take
    effect across the entire set of data. If there were 100 hits and the
    user is looking at the first 15, then clicks on the column heading, the
    JTable would display the last 15 in reverse order. But again, I can't
    have the full 100 (or 1,000 or 10,000) available locally; I would need
    to query. I can query for the "first 15, descending order", that's not
    a problem. But how do I go about modifying TableSorter.java to do this?
    When the user clicks on the header to sort by the column, instead of
    actually sorting, I want to send a query and repopulate the table based
    on the query.

    Any pointers, hints, etc. gratefully accepted. I'm sure this is a
    dumb question, but I can't seem to figure it out.

    Monique Y. Mudama, Jun 27, 2005
    1. Advertisements

  2. On 2005-06-27, Monique Y. Mudama penned:


    Looks like I was making things too complicated. A listener on the
    JTableHeader ... that's what I needed.

    Monique Y. Mudama, Jun 28, 2005
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tivo Escobar
    Apr 12, 2007
  2. Lukasz
    Michael Rauscher
    Aug 24, 2006
  3. Tintin92
    Andrew Thompson
    Feb 14, 2007
  4. Amir  Michail
    Carl Banks
    Mar 4, 2009
  5. Haircuts Are Important
    Haircuts Are Important
    Jun 4, 2013

Share This Page