--- old/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java 2016-01-29 13:18:14.340491900 +0530 +++ new/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java 2016-01-29 13:18:13.807924300 +0530 @@ -791,12 +791,15 @@ return page; } - final GraphicsConfiguration gc = - GraphicsEnvironment.getLocalGraphicsEnvironment(). - getDefaultScreenDevice().getDefaultConfiguration(); - Rectangle bounds = gc.getBounds(); - int x = bounds.x+bounds.width/3; - int y = bounds.y+bounds.height/3; + GraphicsConfiguration grCfg = null; + Window w = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow(); + if (w != null) { + grCfg = w.getGraphicsConfiguration(); + } else { + grCfg = GraphicsEnvironment.getLocalGraphicsEnvironment(). + getDefaultScreenDevice().getDefaultConfiguration(); + } + final GraphicsConfiguration gc = grCfg; PrintService service = java.security.AccessController.doPrivileged( new java.security.PrivilegedAction() { @@ -814,6 +817,11 @@ return null; } + // we position the dialog a little beyond the upper-left corner of the window + // which is consistent with the NATIVE page dialog + Rectangle bounds = gc.getBounds(); + int x = bounds.x+50; + int y = bounds.y+50; ServiceDialog pageDialog = new ServiceDialog(gc, x, y, service, DocFlavor.SERVICE_FORMATTED.PAGEABLE, attributes, (Frame)null); @@ -893,9 +901,15 @@ * We raise privilege when we put up the dialog, to avoid * the "warning applet window" banner. */ - final GraphicsConfiguration gc = - GraphicsEnvironment.getLocalGraphicsEnvironment(). - getDefaultScreenDevice().getDefaultConfiguration(); + GraphicsConfiguration grCfg = null; + Window w = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow(); + if (w != null) { + grCfg = w.getGraphicsConfiguration(); + } else { + grCfg = GraphicsEnvironment.getLocalGraphicsEnvironment(). + getDefaultScreenDevice().getDefaultConfiguration(); + } + final GraphicsConfiguration gc = grCfg; PrintService service = java.security.AccessController.doPrivileged( new java.security.PrivilegedAction() { @@ -940,9 +954,10 @@ } } - Rectangle bounds = gc.getBounds(); - int x = bounds.x+bounds.width/3; - int y = bounds.y+bounds.height/3; + // we position the dialog a little beyond the upper-left corner of the window + // which is consistent with the NATIVE print dialog + int x = 50; + int y = 50; PrintService newService; // temporarily add an attribute pointing back to this job. PrinterJobWrapper jobWrapper = new PrinterJobWrapper(this);