modules/graphics/src/main/java/com/sun/prism/j2d/print/J2DPrinterJob.java

Print this page
rev 8895 : RT-39689: Better docs and error checking if Printing or Dialogs called from Animation

*** 125,134 **** --- 125,139 ---- boolean rv = false; syncSettingsToAttributes(); if (!Toolkit.getToolkit().isFxUserThread()) { rv = pJob2D.printDialog(printReqAttrSet); } else { + // If we are on the event thread, we need to check whether we are + // allowed to call a nested event handler. + if (!Toolkit.getToolkit().canStartNestedEventLoop()) { + throw new IllegalStateException("Printing is allowed only while handling system events"); + } rv = showPrintDialogWithNestedLoop(owner); } if (rv) { updateSettingsFromDialog(); }
*** 174,183 **** --- 179,193 ---- syncSettingsToAttributes(); if (!Toolkit.getToolkit().isFxUserThread()) { PageFormat pf = pJob2D.pageDialog(printReqAttrSet); rv = pf != null; } else { + // If we are on the event thread, we need to check whether we are + // allowed to call a nested event handler. + if (!Toolkit.getToolkit().canStartNestedEventLoop()) { + throw new IllegalStateException("Printing is allowed only while handling system events"); + } rv = showPageDialogFromNestedLoop(owner); } if (rv) { updateSettingsFromDialog(); }
*** 696,705 **** --- 706,722 ---- * This gets really interesting if the FX Node is attached to a * scene, as you are only supposed to update it on the FX thread * and the PG code can only access it during sync. */ public boolean print(PageLayout pageLayout, Node node) { + if (Toolkit.getToolkit().isFxUserThread()) { + // If we are on the event thread, we need to check whether we are + // allowed to call a nested event handler. + if (!Toolkit.getToolkit().canStartNestedEventLoop()) { + throw new IllegalStateException("Printing is allowed only while handling system events"); + } + } if (jobError || jobDone) { return false; }