I have a very long j table created using entity to database with more than 2000 records i want to print the table using java code into multiple pages divided as required .. need help or code to implement this
-
Possible duplicate of [How to print a large JPanel in several page](https://stackoverflow.com/questions/25919083/how-to-print-a-large-jpanel-in-several-page) – Nico Haase Jul 26 '18 at 12:37
-
*"want to print the table"* What do you mean by 'print'? As in, 'display in multiple parts in a GUI' or 'print on multiple pages of paper' or ..? – Andrew Thompson Jul 26 '18 at 12:42
-
Possible duplicate of [JTable row limitation](https://stackoverflow.com/a/6175860/418556). – Andrew Thompson Jul 26 '18 at 12:43
-
Multiple pages is simple with a PrintJob. A TableModel could be wrapped in a TableModel that only select the rows of some page, And then you could make a JTable on every page. – Joop Eggen Jul 26 '18 at 12:48
-
in multiple paper of a4 size – Tauqeer Akhtar Jul 26 '18 at 12:51
-
in multiple paper of a4 size . it is a scrollable table with very much data. i want to print the table into several pages in as much as it fits. – Tauqeer Akhtar Jul 26 '18 at 12:58
1 Answers
From what I understand from your question you wish to have a few counters used while creating a set of objects for some JPanels or some sort of other storage for them such as in this code:
int i = 0; //Use this to count the number of entries already placed
int counter = n; //A second counter to count the number you want displayed per page (n)
while(i<2000){
//Here, code for creating a container for the next n set of items can be placed
while(i<counter){
//Here is where you put however you wish to create and display your items
i++; //Progressing the counter for database entries
}
counter = counter+n; //Progressing the counter for how many you want per page
}
This should work for formats where your entries are processed into an array or data structure of some kind that will allow you use of the counters to navigate through it, hopefully this has helped somewhat

- 21
- 3