< prev index next >

src/java.desktop/share/classes/sun/print/PrintJob2D.java

Print this page

        

*** 292,301 **** --- 292,302 ---- /** * The thread on which PrinterJob is running. * This is different than the applications thread. */ private Thread printerJobThread; + private boolean printFinished; public PrintJob2D(Frame frame, String doctitle, final Properties props) { this.props = props; this.jobAttributes = new JobAttributes();
*** 788,807 **** } /* We'll block here until a new graphics becomes * available. */ - currentGraphics = graphicsToBeDrawn.pop(); if (currentGraphics instanceof PeekGraphics) { ! ( (PeekGraphics) currentGraphics).setAWTDrawingOnly(); graphicsDrawn.append(currentGraphics); currentGraphics = graphicsToBeDrawn.pop(); } - if (currentGraphics != null) { /* In the PrintJob API, the origin is at the upper- * left of the imageable area when using the new "printable" * origin attribute, otherwise its the physical origin (for --- 789,813 ---- } /* We'll block here until a new graphics becomes * available. */ currentGraphics = graphicsToBeDrawn.pop(); + if (currentGraphics == null && printFinished) { + synchronized (this) { + startPrinterJobThread(); + notify(); + } + currentGraphics = graphicsToBeDrawn.pop(); + } if (currentGraphics instanceof PeekGraphics) { ! ((PeekGraphics) currentGraphics).setAWTDrawingOnly(); graphicsDrawn.append(currentGraphics); currentGraphics = graphicsToBeDrawn.pop(); } if (currentGraphics != null) { /* In the PrintJob API, the origin is at the upper- * left of the imageable area when using the new "printable" * origin attribute, otherwise its the physical origin (for
*** 827,837 **** */ printGraphics = new ProxyPrintGraphics(currentGraphics.create(), this); } - return printGraphics; } /** * Returns the dimensions of the page in pixels. --- 833,842 ----
*** 981,996 **** --- 986,1003 ---- result = PAGE_EXISTS; } else { result = NO_SUCH_PAGE; } + return result; } private void startPrinterJobThread() { printerJobThread = new ManagedLocalsThread(this, "printerJobThread"); printerJobThread.start(); + printFinished = false; } public void run() {
*** 1001,1012 **** } /* Close the message queues so that nobody is stuck * waiting for one. */ ! graphicsToBeDrawn.closeWhenEmpty(); ! graphicsDrawn.close(); } private class MessageQ { private String qid="noname"; --- 1008,1020 ---- } /* Close the message queues so that nobody is stuck * waiting for one. */ ! printFinished = true; ! //graphicsToBeDrawn.closeWhenEmpty(); ! //graphicsDrawn.close(); } private class MessageQ { private String qid="noname";
*** 1057,1066 **** --- 1065,1077 ---- if (queue.size() > 0) { g = queue.remove(0); notify(); } else { + if (printFinished) { + break; + } try { wait(2000); } catch (InterruptedException e) { // do nothing. }
< prev index next >