我有一个很长的j表,该表使用实体创建了具有2000多个记录的数据库,我想使用java代码将表打印成按需要划分的多个页面..需要帮助或代码来实现
答案 0 :(得分:0)
根据我对您的问题的了解,您希望在为某些JPanels或为其创建某种其他存储的对象集时使用一些计数器,例如以下代码:
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
}
这应该适用于将条目处理为某种数组或某种数据结构的格式,这些格式将允许您使用计数器进行浏览,希望这有所帮助