--- old/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java 2018-05-24 15:22:30.160327694 -0700 +++ new/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java 2018-05-24 15:22:29.940327698 -0700 @@ -74,6 +74,7 @@ import javax.print.attribute.standard.Copies; import javax.print.attribute.standard.Destination; import javax.print.attribute.standard.DialogTypeSelection; +import javax.print.attribute.standard.DialogOwner; import javax.print.attribute.standard.Fidelity; import javax.print.attribute.standard.JobName; import javax.print.attribute.standard.JobSheets; @@ -830,8 +831,15 @@ int x = gcBounds.x+50; int y = gcBounds.y+50; ServiceDialog pageDialog; + boolean setOnTop = false; if (onTop != null) { attributes.add(onTop); + Window owner = onTop.getOwner(); + if (owner != null) { + w = owner; // use the one specifed by the app + } else if (onTop.getID() == 0) { + setOnTop = true; + } } if (w instanceof Frame) { pageDialog = new ServiceDialog(gc, x, y, service, @@ -842,6 +850,9 @@ DocFlavor.SERVICE_FORMATTED.PAGEABLE, attributes, (Dialog)w); } + if (setOnTop) { + pageDialog.setAlwaysOnTop(true); + } Rectangle dlgBounds = pageDialog.getBounds(); @@ -988,8 +999,7 @@ * (it might be set in java.awt.PrintJob.printDialog) */ if (attributes.get(DialogOwner.class) == null) { - attributes.add(w instanceof Frame ? new DialogOwner((Frame)w) : - new DialogOwner((Dialog)w)); + attributes.add(new DialogOwner(w)); } } else { grCfg = GraphicsEnvironment.getLocalGraphicsEnvironment(). @@ -2581,7 +2591,7 @@ } } - private DialogOnTop onTop = null; + private DialogOwner onTop = null; private long parentWindowID = 0L; @@ -2597,7 +2607,7 @@ private void setParentWindowID(PrintRequestAttributeSet attrs) { parentWindowID = 0L; - onTop = (DialogOnTop)attrs.get(DialogOnTop.class); + onTop = (DialogOwner)attrs.get(DialogOwner.class); if (onTop != null) { parentWindowID = onTop.getID(); }