JAL-2464 fix cancel tree print behaviour
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 23 Mar 2017 15:10:52 +0000 (15:10 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 23 Mar 2017 15:10:52 +0000 (15:10 +0000)
src/jalview/gui/TreeCanvas.java

index 54eed1a..9a38d4c 100755 (executable)
@@ -549,7 +549,16 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable,
   public void run()
   {
     PrinterJob printJob = PrinterJob.getPrinterJob();
-    PageFormat pf = printJob.pageDialog(printJob.defaultPage());
+    PageFormat defaultPage = printJob.defaultPage();
+    PageFormat pf = printJob.pageDialog(defaultPage);
+
+    if (defaultPage == pf)
+    {
+      /*
+       * user cancelled
+       */
+      return;
+    }
 
     printJob.setPrintable(this, pf);