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)