Pagination in jtable

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • saiindu
    New Member
    • Mar 2008
    • 14

    Pagination in jtable

    I want to do paging concept in my jtable by displaying 10 records per page if i choose 25 in rowcount, it has to split 10 in each page balance records in last page using previous and next buttons. Also After complete filling the 10 records and going to next page and fill the balance records. If i give back button the information which i gave should display.. Pls guide me in doing this task.
  • Nepomuk
    Recognized Expert Specialist
    • Aug 2007
    • 3111

    #2
    What have you done so far? In what format are those records stored? And can you give an example for the records and the output, so that it will be easier to understand? (Maybe just display 3 records per page in the example, to simplify things...)

    Greetings,
    Nepomuk

    Comment

    • saiindu
      New Member
      • Mar 2008
      • 14

      #3
      According to the row count records r splitted to 10 per page. That is if i give 12 records in rowcount.It'll show 10 records in one page and 2 records in second page. Records in jtable r saved in arraylist and using tokenizer we r retrieving the records. And i've used the below code to split the records as 10 per page.
      This is called in the Next button click event
      [code=java]
      private void Assign_Page2(in t RowCount) {
      System.out.prin tln("4");
      if (Page == 1) {
      System.out.prin tln("5");
      Page = (RowCount / Count) + 1;
      } else {
      System.out.prin tln("6");
      Page --;
      }
      if (Page * Count <= RowCount) {
      System.out.prin tln("7");
      int start = ((Page - 1) * Count) + 1;
      int end = Page * Count;
      Tableshow(start , end);
      } else {
      System.out.prin tln("8");
      int start = ((Page - 1) * Count) + 1;
      int end = RowCount;
      Tableshow(start , end);
      }
      }
      [/code]
      Now i want to store and retrieve the values i give in each page using arraylist tokenizer. If i give back button the values which i gave in page 1 or page 2 should display. So kindly help
      Last edited by Nepomuk; Aug 28 '08, 08:18 AM. Reason: Please use [code] tags

      Comment

      • BigDaddyLH
        Recognized Expert Top Contributor
        • Dec 2007
        • 1216

        #4
        Try your favourite Internet search engine. It's not hard, just choose a few keywords like :"JTable" and "Paging". Here is an example:



        Now look at the hits you get. The very first is an article entitled "Paging in a Swing JTable".

        This fantastic technique (searching the Internet) is great for not only answering Java questions, or other programming puzzles, but for just about anything. Try it, and let your friends know about it, too!

        Comment

        • saiindu
          New Member
          • Mar 2008
          • 14

          #5
          All i need is not given in that article given in that site. I want to save and retrieve the values whever i need in that paging without database. I already stored that using arraylist but i dont know how to print in required page.

          Comment

          • saiindu
            New Member
            • Mar 2008
            • 14

            #6
            I need some samples which is by using previous and next pages and the records every page can be stored and viewed using Arraylist..

            Comment

            Working...