< prev index next >

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

Print this page

        

@@ -72,10 +72,11 @@
 import javax.print.attribute.ResolutionSyntax;
 import javax.print.attribute.Size2DSyntax;
 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;
 import javax.print.attribute.standard.Media;
 import javax.print.attribute.standard.MediaPrintableArea;

@@ -828,22 +829,32 @@
         // which is consistent with the NATIVE page dialog
         Rectangle gcBounds = gc.getBounds();
         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,
                                            DocFlavor.SERVICE_FORMATTED.PAGEABLE,
                                            attributes,(Frame)w);
         } else {
             pageDialog = new ServiceDialog(gc, x, y, service,
                                            DocFlavor.SERVICE_FORMATTED.PAGEABLE,
                                            attributes, (Dialog)w);
         }
+        if (setOnTop) {
+            pageDialog.setAlwaysOnTop(true);
+        }
 
         Rectangle dlgBounds = pageDialog.getBounds();
 
         // if portion of dialog is not within the gc boundary
         if (!gcBounds.contains(dlgBounds)) {

@@ -986,12 +997,11 @@
              /* 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) {
-                attributes.add(w instanceof Frame ? new DialogOwner((Frame)w) :
-                                                    new DialogOwner((Dialog)w));
+                attributes.add(new DialogOwner(w));
             }
         } else {
             grCfg = GraphicsEnvironment.getLocalGraphicsEnvironment().
                         getDefaultScreenDevice().getDefaultConfiguration();
         }

@@ -2579,11 +2589,11 @@
         } else {
             return new String(out_chars, 0, pos);
         }
     }
 
-    private DialogOnTop onTop = null;
+    private DialogOwner onTop = null;
 
     private long parentWindowID = 0L;
 
     /* Called from native code */
     private long getParentWindowID() {

@@ -2595,11 +2605,11 @@
         onTop = null;
     }
 
     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();
         }
     }
 }
< prev index next >