【问题标题】:printing very long jtable into multiple pages将很长的 jtable 打印到多个页面中
【发布时间】:2018-07-26 12:32:45
【问题描述】:

我有一个很长的 j 表,使用实体到数据库创建了 2000 多条记录

【问题讨论】:

  • “想打印表格” '打印'是什么意思?例如,“在 GUI 中的多个部分显示”或“在多页纸上打印”或 ..?
  • JTable row limitation 的可能重复项。
  • 多页使用 PrintJob 很简单。一个 TableModel 可以包装在一个只选择某个页面的行的 TableModel 中,然后你可以在每个页面上创建一个 JTable。
  • 多张a4纸

标签: java database swing printing jtable


【解决方案1】:

根据我从您的问题中了解到的情况,您希望在为某些 JPanel 或为它们创建某种其他存储的一组对象时使用一些计数器,例如在此代码中:

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 }

这应该适用于您的条目被处理成数组或某种数据结构的格式,这样您就可以使用计数器来浏览它,希望这有所帮助

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-10
    • 2018-11-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多