如何在java中打印jtable的完整数据

时间:2019-03-13 18:05:50

标签: java jtable indexoutofboundsexception messageformat

 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) 

0 个答案:

没有答案