Java JTable在较高分辨率的屏幕上打印得太小

时间:2018-07-02 21:48:41

标签: java swing printing jtable

在高分辨率屏幕上打印jtable时,为什么字体太小?在1600x900上看起来不错,但是当我在1920x1200之类的高分辨率屏幕上打印同一张表时,字体变得太小。

HashPrintRequestAttributeSet attr = null;

attr = new HashPrintRequestAttributeSet();
attr.add(MediaSizeName.ISO_A4);
attr.add(OrientationRequested.LANDSCAPE);
attr.add(new JobName(persistentPrintText, Locale.ENGLISH));

MediaSize mediaSize = MediaSize.ISO.A4;
float mediaWidth = mediaSize.getX(Size2DSyntax.MM);
float mediaHeight = mediaSize.getY(Size2DSyntax.MM);
float imageableX = 10; //mm left and right margins
float imageableY = 10; //mm top and bottom margins
float imageableWidth = (mediaWidth - (2 * imageableX));
float imageableHeight = (mediaHeight - (2 * imageableY));
MediaPrintableArea imageableArea = new MediaPrintableArea(
        imageableX, imageableY,
        imageableWidth, imageableHeight, Size2DSyntax.MM);
attr.add(imageableArea);
PrinterJob job = PrinterJob.getPrinterJob();
job.setPrintable(jTableCivil1Info.getPrintable(JTable.PrintMode.FIT_WIDTH, header, new MessageFormat("Page {0}")));
if (job.printDialog(attr)) {
    try {
        job.print(attr);
    } catch (PrinterException pe) {
        JOptionPane.showMessageDialog(null, pe.getMessage());
    }
}

0 个答案:

没有答案