如何设置JTable的字体和大小以进行打印

时间:2015-04-21 10:44:24

标签: java printing jtable

我正在尝试打印POS的发票清单。我想打印JTable和一些JComponent。我正在使用爱普生打印机,但它打印了一张长纸。如何更改要打印的表的大小?这是我使用的代码:

MessageFormat header = new MessageFormat("welcome ");
MessageFormat footer = new MessageFormat("thank for fisit");
try {
     PrintRequestAttributeSet set = new HashPrintRequestAttributeSet();
     set.add(OrientationRequested.LANDSCAPE);

     jTable2.print(JTable.PrintMode.FIT_WIDTH, header, footer, false, set, false);
     jTextField8.print();


 } catch (java.awt.print.PrinterException e) {
     JOptionPane.showMessageDialog(null, "\n" + "Error from Printer Job "
            + "\n" + e);   
 }

0 个答案:

没有答案