< prev index next >

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

Print this page

        

*** 789,804 **** } updateAttributesWithPageFormat(pservice, page, attributes); 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; PrintService service = java.security.AccessController.doPrivileged( new java.security.PrivilegedAction<PrintService>() { public PrintService run() { PrintService service = getPrintService(); --- 789,807 ---- } updateAttributesWithPageFormat(pservice, page, attributes); return page; } ! 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<PrintService>() { public PrintService run() { PrintService service = getPrintService();
*** 812,824 **** --- 815,855 ---- if (service == null) { 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 gcBounds = gc.getBounds(); + int x = gcBounds.x+50; + int y = gcBounds.y+50; ServiceDialog pageDialog = new ServiceDialog(gc, x, y, service, DocFlavor.SERVICE_FORMATTED.PAGEABLE, attributes, (Frame)null); + + Rectangle dlgBounds = pageDialog.getBounds(); + + // if portion of dialog is not within the gc boundary + if (!gcBounds.contains(dlgBounds)) { + + // 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; + } + pageDialog.setBounds(x, y, dlgBounds.width, dlgBounds.height); + } pageDialog.show(); if (pageDialog.getStatus() == ServiceDialog.APPROVE) { PrintRequestAttributeSet newas = pageDialog.getAttributes();
*** 891,903 **** * to a chosen printer. * * We raise privilege when we put up the dialog, to avoid * the "warning applet window" banner. */ ! final GraphicsConfiguration gc = ! GraphicsEnvironment.getLocalGraphicsEnvironment(). getDefaultScreenDevice().getDefaultConfiguration(); PrintService service = java.security.AccessController.doPrivileged( new java.security.PrivilegedAction<PrintService>() { public PrintService run() { PrintService service = getPrintService(); --- 922,940 ---- * to a chosen printer. * * We raise privilege when we put up the dialog, to avoid * the "warning applet window" banner. */ ! 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<PrintService>() { public PrintService run() { PrintService service = getPrintService();
*** 938,950 **** services = new PrintService[1]; services[0] = service; } } ! Rectangle bounds = gc.getBounds(); ! int x = bounds.x+bounds.width/3; ! int y = bounds.y+bounds.height/3; PrintService newService; // temporarily add an attribute pointing back to this job. PrinterJobWrapper jobWrapper = new PrinterJobWrapper(this); attributes.add(jobWrapper); try { --- 975,988 ---- services = new PrintService[1]; services[0] = service; } } ! // 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); attributes.add(jobWrapper); try {
< prev index next >