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.
Pagination in jtable
Collapse
X
-
-
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 -
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 helpComment
-
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
Comment