我在JBUILDER下开发了一个应用程序,采用的是CARDLAYOUT,在每一层中都有一个JSROLLPANE,然后再放一个JTABLE,然后从数据库中读取数据,放入不同的JTABLE中,有需求要讲JTABLE中的数据打印出来,而且只打印当前可见的那层表格中的记录.有的表格中的数据很多,要实现分页打印。我目前的解决方案是在每层中加入一个JBUTTON,然后写事件处理代码来实现打印功能,将整个JSROLLPANE控件作为图片打印出来。可是不能分页,而且页面太大,不能打完整。请高手指教,有没有其他的解决方案注:我现在身边没有参考书,最好能给我代码

解决方案 »

  1.   

    Jdk1.5的JTable不是支持分页打印的功能了?直接就jTable1.print()即可打印了print
    public boolean print()
                  throws PrinterException
    A convenience method that displays a printing dialog, and then prints this JTable in mode PrintMode.FIT_WIDTH, with no header or footer text. A modal progress dialog, with an abort option, will be shown for the duration of printing. 
    Note: In headless mode, no dialogs will be shown. 
    Returns:
    true, unless printing is cancelled by the user 
    Throws: 
    PrinterException - if an error in the print system causes the job to be aborted
      

  2.   

    可以试试 java 电子表格控件.  
    http://www.finereport.com
      

  3.   

    如果是设计成图片打印,打印速度太慢了!我想问的是你JTable中的数据是存放在什么对象中?