473,372 Members | 1,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 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 10085
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

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

Similar topics

by: Ben Munday | last post by:
Hi all, I have a problem with a Checkbox in a JTable. When i add the Checkbox into the JTable it displays the String representation of the Checkbox, which is not what i want. So, i created a...
by: asd | last post by:
I need to make the cells in the 1st column look like the column header. I tried the following code but it didn't change anything: private void rendererTest() { TableColumn column =...
by: raysaun | last post by:
I am trying to set a TableCellEditor for a JTable, however, the editor never seems to get called. I can not even get a simplified version (below) to work. When I put a breakpoint on the return...
by: sivaprasad06 | last post by:
Hi, I have a editable combo box editor as a cell editor for JTable. I want use only key board to enter data into jtable. so i am using ALT+Down comobination for making cell editiable in the...
by: nuria | last post by:
hi, I have an editable JTable, when you are editing it and press F8 shows a dialog and then go again to the JTable window but the focus goes to a JtextField component, go with the tab for the...
by: Andrea Sansottera | last post by:
Hi fellows, I was wondering if in the Java API there's a way to easily map a disconnected RowSet to a JTable... I have looked at the doc but i did not found anything. What I want is simply do...
by: onsir | last post by:
I have code like this, but still wrong. how to show data from database in JTable. package my.JavaNetBean; import java.sql.*; import java.io.*; import java.sql.Connection; import...
by: blazedaces | last post by:
Hi guys, what I'm I have is a jtable with boolean variables in the first column and text in the next two (checkboxes). I want my tableChanged method to make it so when I check one of the checkboxes...
by: moizpalitanawala | last post by:
Hello friends, How to add data to JTable from a .txt file. I had seen this code from one of the tutorial from java.com. This code doesnt take any input. But shows what is written in the array....
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.