471,851 Members | 904 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,851 software developers and data experts.

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.
Aug 22 '08 #1
5 9925
3,112 Expert 2GB
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...)

Aug 22 '08 #2
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
Expand|Select|Wrap|Line Numbers
  1. private void Assign_Page2(int RowCount) {
  2.         System.out.println("4");
  3.         if (Page == 1) {
  4.             System.out.println("5");
  5.             Page = (RowCount / Count) + 1;            
  6.         } else {
  7.             System.out.println("6");
  8.             Page --;
  9.         }
  10.         if (Page * Count <= RowCount) {
  11.             System.out.println("7");
  12.             int start = ((Page - 1) * Count) + 1;
  13.             int end = Page * Count;
  14.             Tableshow(start, end);
  15.         } else {
  16.             System.out.println("8");
  17.             int start = ((Page - 1) * Count) + 1;
  18.             int end = RowCount;
  19.             Tableshow(start, end);
  20.         }
  21.     }
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
Aug 28 '08 #3
1,216 Expert 1GB
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!
Aug 28 '08 #4
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.
Aug 29 '08 #5
I need some samples which is by using previous and next pages and the records every page can be stored and viewed using Arraylist..
Aug 29 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Ben Munday | last post: by
1 post views Thread by asd | last post: by
1 post views Thread by raysaun | last post: by
reply views Thread by sivaprasad06 | last post: by
reply views Thread by nuria | last post: by
1 post views Thread by Andrea Sansottera | last post: by
1 post views Thread by onsir | last post: by
reply views Thread by NeoPa | last post: by
reply views Thread by YellowAndGreen | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.