< prev index next >

src/java.desktop/share/classes/javax/print/ServiceUI.java

Print this page

        

@@ -209,22 +209,28 @@
                                        flavor, attributes,
                                        (Dialog)owner);
         }
         Rectangle dlgBounds = dialog.getBounds();
 
-        // get union of all GC bounds
-        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
-        GraphicsDevice[] gs = ge.getScreenDevices();
-        for (int j=0; j<gs.length; j++) {
-            gcBounds =
-                gcBounds.union(gs[j].getDefaultConfiguration().getBounds());
-        }
-
         // if portion of dialog is not within the gc boundary
         if (!gcBounds.contains(dlgBounds)) {
-            // put in the center relative to parent frame/dialog
-            dialog.setLocationRelativeTo(owner);
+            
+            // if dialog bounds exceed window bounds, positioning the dialog 
+            // by moving it (bounds.x + bounds.width) - dlgBound.width 
+            // If it results in dialog moving beyond the window bounds at top-left, 
+            // then position it at window top-left
+            if ((gcBounds.x + gcBounds.width - dlgBounds.width) > gcBounds.x) {
+                x = (gcBounds.x + gcBounds.width) - dlgBounds.width;                
+            } else {
+                x = gcBounds.x;                
+            }
+            if ((gcBounds.y + gcBounds.height - dlgBounds.height) > gcBounds.y) {
+                y = (gcBounds.y + gcBounds.height) - dlgBounds.height;                
+            } else {
+                y = gcBounds.y;                
+            }            
+            dialog.setBounds(x, y, dlgBounds.width, dlgBounds.height);
         }
         dialog.show();
 
         if (dialog.getStatus() == ServiceDialog.APPROVE) {
             PrintRequestAttributeSet newas = dialog.getAttributes();
< prev index next >