--- old/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java 2016-08-26 13:30:10.627212400 +0530 +++ new/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java 2016-08-26 13:30:10.056139900 +0530 @@ -30,7 +30,6 @@ import java.awt.Color; import java.awt.Dialog; import java.awt.Frame; -import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.GraphicsConfiguration; import java.awt.GraphicsEnvironment; @@ -39,7 +38,6 @@ import java.awt.Rectangle; import java.awt.Shape; import java.awt.geom.AffineTransform; -import java.awt.geom.Area; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; @@ -55,7 +53,6 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; -import java.util.Enumeration; import java.util.Locale; import sun.awt.image.ByteInterleavedRaster; @@ -74,7 +71,6 @@ import javax.print.attribute.PrintRequestAttributeSet; import javax.print.attribute.ResolutionSyntax; import javax.print.attribute.Size2DSyntax; -import javax.print.attribute.standard.Chromaticity; import javax.print.attribute.standard.Copies; import javax.print.attribute.standard.Destination; import javax.print.attribute.standard.DialogTypeSelection; @@ -836,9 +832,16 @@ Rectangle gcBounds = gc.getBounds(); int x = gcBounds.x+50; int y = gcBounds.y+50; - ServiceDialog pageDialog = new ServiceDialog(gc, x, y, service, + ServiceDialog pageDialog; + if (w instanceof Frame) { + pageDialog = new ServiceDialog(gc, x, y, service, DocFlavor.SERVICE_FORMATTED.PAGEABLE, - attributes, (Frame)null); + attributes, (Frame)w); + } else { + pageDialog = new ServiceDialog(gc, x, y, service, + DocFlavor.SERVICE_FORMATTED.PAGEABLE, + attributes, (Dialog)w); + } Rectangle dlgBounds = pageDialog.getBounds(); // if portion of dialog is not within the gc boundary @@ -944,6 +947,17 @@ Window w = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow(); if (w != null) { grCfg = w.getGraphicsConfiguration(); + /* Add DialogOwner attribute to set the owner of this print dialog + * only if it is not set already + * (it might be set in java.awt.PrintJob.printDialog) + */ + if (attributes.get(DialogOwner.class) == null) { + if (w instanceof Frame) { + attributes.add(new DialogOwner((Frame)w)); + } else if (w instanceof Dialog) { + attributes.add(new DialogOwner((Dialog)w)); + } + } } else { grCfg = GraphicsEnvironment.getLocalGraphicsEnvironment(). getDefaultScreenDevice().getDefaultConfiguration();