avoid deprecation and ensure dialog close event is passed to client
authorjprocter <jprocter@compbio.dundee.ac.uk>
Mon, 26 Sep 2011 09:04:53 +0000 (10:04 +0100)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Mon, 26 Sep 2011 09:04:53 +0000 (10:04 +0100)
src/jalview/gui/JalviewDialog.java

index 4630cfc..3b10e86 100644 (file)
@@ -4,6 +4,8 @@ import java.awt.Container;
 import java.awt.Rectangle;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowListener;
 
 import javax.swing.JButton;
 import javax.swing.JDialog;
@@ -32,14 +34,14 @@ public abstract class JalviewDialog extends JPanel
 
         public void run()
         {
-          frame.show();
+          frame.setVisible(true);
         }
 
       }).start();
     }
     else
     {
-      frame.show();
+      frame.setVisible(true);
     }
   }
 
@@ -80,7 +82,56 @@ public abstract class JalviewDialog extends JPanel
         closeDialog();
       }
     });
-
+    frame.addWindowListener(new WindowListener()
+    {
+      
+      @Override
+      public void windowOpened(WindowEvent e)
+      {
+        // TODO Auto-generated method stub
+        
+      }
+      
+      @Override
+      public void windowIconified(WindowEvent e)
+      {
+        // TODO Auto-generated method stub
+        
+      }
+      
+      @Override
+      public void windowDeiconified(WindowEvent e)
+      {
+        // TODO Auto-generated method stub
+        
+      }
+      
+      @Override
+      public void windowDeactivated(WindowEvent e)
+      {
+        // TODO Auto-generated method stub
+        
+      }
+      
+      @Override
+      public void windowClosing(WindowEvent e)
+      {
+        // user has cancelled the dialog
+        closeDialog();
+      }
+      
+      @Override
+      public void windowClosed(WindowEvent e)
+      {
+      }
+      
+      @Override
+      public void windowActivated(WindowEvent e)
+      {
+        // TODO Auto-generated method stub
+        
+      }
+    });
   }
   /**
    * clean up and raise the 'dialog closed' event by calling raiseClosed