--- old/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java 2017-03-10 14:13:58.029395724 -0800 +++ new/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java 2017-03-10 14:13:57.897395725 -0800 @@ -785,7 +785,9 @@ PrintService pservice = getPrintService(); PageFormat pageFrmAttrib = attributeToPageFormat(pservice, attributes); + setParentWindowID(attributes); PageFormat page = pageDialog(pageFrmAttrib); + clearParentWindowID(); // If user cancels the dialog, pageDialog() will return the original // page object and as per spec, we should return null in that case. @@ -923,7 +925,9 @@ } + setParentWindowID(attributes); boolean ret = printDialog(); + clearParentWindowID(); this.attributes = attributes; return ret; @@ -2539,4 +2543,23 @@ return new String(out_chars, 0, pos); } } + + private long parentWindowID = 0L; + + /* Called from native code */ + private long getParentWindowID() { + return parentWindowID; + } + + private void clearParentWindowID() { + parentWindowID = 0L; + } + + private void setParentWindowID(PrintRequestAttributeSet attrs) { + parentWindowID = 0L; + DialogOnTop onTop = (DialogOnTop)attrs.get(DialogOnTop.class); + if (onTop != null) { + parentWindowID = onTop.getID(); + } + } }