首页 > 解决方案 > 如何在java中打印jtable的完整数据

问题描述

 MessageFormat header = new MessageFormat("MEHBOOB RCIE MILL  ");
           MessageFormat footer = new MessageFormat("TEST");
        try {
            jTableReport.print(JTable.PrintMode.FIT_WIDTH, header, footer);
        } catch (java.awt.print.PrinterException e) {
            System.err.format("Cannot print %s%n", e.getMessage());
        }

我这样做是为了在数据为一页时在打印机上打印数据它工作正常但是当数据增加意味着 3 或 5 页时它打印异常线程“AWT-EventQueue-0”中的异常

java.lang.ArrayIndexOutOfBoundsException: -1
    at sun.font.ExtendedTextSourceLabel.getJustificationInfos(ExtendedTextSourceLabel.java:988)
    at java.awt.font.TextLine.getJustifiedLine(TextLine.java:1358)
    at java.awt.font.TextLayout.getJustifiedLayout(TextLayout.java:817)
    at sun.swing.SwingUtilities2.drawString(SwingUtilities2.java:518)
    at sun.swing.SwingUtilities2.drawStringUnderlineCharAt(SwingUtilities2.java:612)
    at javax.swing.plaf.synth.SynthGraphicsUtils.paintText(SynthGraphicsUtils.java:340)
    at javax.swing.plaf.synth.SynthGraphicsUtils.paintText(SynthGraphicsUtils.java:319)`enter code here`
    at javax.swing.plaf.synth.SynthGraphicsUtils.paintText(SynthGraphicsUtils.java:410) 

标签: javajtableindexoutofboundsexceptionmessageformat

解决方案


推荐阅读