Do not cache PrinterJob instances. Cache is evil

This commit is contained in:
Federico Fissore 2015-05-28 14:55:05 +02:00
parent a9cdd44d27
commit 8c83281a19
1 changed files with 2 additions and 9 deletions

View File

@ -119,7 +119,6 @@ public class Editor extends JFrame implements RunnerListener {
boolean untitled;
PageFormat pageFormat;
PrinterJob printerJob;
// file, sketch, and tools menus for re-inserting items
JMenu fileMenu;
@ -2760,15 +2759,11 @@ public class Editor extends JFrame implements RunnerListener {
* Handler for File → Page Setup.
*/
public void handlePageSetup() {
//printerJob = null;
if (printerJob == null) {
printerJob = PrinterJob.getPrinterJob();
}
PrinterJob printerJob = PrinterJob.getPrinterJob();
if (pageFormat == null) {
pageFormat = printerJob.defaultPage();
}
pageFormat = printerJob.pageDialog(pageFormat);
//System.out.println("page format is " + pageFormat);
}
@ -2778,9 +2773,7 @@ public class Editor extends JFrame implements RunnerListener {
public void handlePrint() {
statusNotice(_("Printing..."));
//printerJob = null;
if (printerJob == null) {
printerJob = PrinterJob.getPrinterJob();
}
PrinterJob printerJob = PrinterJob.getPrinterJob();
if (pageFormat != null) {
//System.out.println("setting page format " + pageFormat);
printerJob.setPrintable(textarea, pageFormat);