AddToDesktop is synchronized
authoramwaterhouse <Andrew Waterhouse>
Tue, 23 Aug 2005 16:10:53 +0000 (16:10 +0000)
committeramwaterhouse <Andrew Waterhouse>
Tue, 23 Aug 2005 16:10:53 +0000 (16:10 +0000)
src/jalview/gui/Desktop.java

index a705386..9ebbf5b 100755 (executable)
@@ -115,6 +115,7 @@ public class Desktop extends jalview.jbgui.GDesktop
         frame.setLayer(JLayeredPane.PALETTE_LAYER);
         frame.setLocation((int) ((getWidth() - 750) / 2),
             (int) ((getHeight() - 160) / 2));
+
         addInternalFrame(frame, "", 750, 160, false);
 
         discoverer=new jalview.ws.Discoverer(); // Only gets started if gui is displayed.
@@ -128,7 +129,7 @@ public class Desktop extends jalview.jbgui.GDesktop
      * @param w DOCUMENT ME!
      * @param h DOCUMENT ME!
      */
-    public static void addInternalFrame(final JInternalFrame frame,
+    public static synchronized void addInternalFrame(final JInternalFrame frame,
         String title, int w, int h)
     {
         addInternalFrame(frame, title, w, h, true);
@@ -143,7 +144,7 @@ public class Desktop extends jalview.jbgui.GDesktop
      * @param h DOCUMENT ME!
      * @param resizable DOCUMENT ME!
      */
-    public static void addInternalFrame(final JInternalFrame frame,
+    public static synchronized void addInternalFrame(final JInternalFrame frame,
         String title, int w, int h, boolean resizable)
     {
 
@@ -163,17 +164,9 @@ public class Desktop extends jalview.jbgui.GDesktop
       }
 
 
-        desktop.add(frame);
         openFrameCount++;
 
-        try
-        {
-            frame.setSelected(true);
-        }
-        catch (java.beans.PropertyVetoException e)
-        {
-        }
-
+        frame.setVisible(true);
         frame.setClosable(true);
         frame.setResizable(resizable);
         frame.setMaximizable(resizable);
@@ -182,10 +175,21 @@ public class Desktop extends jalview.jbgui.GDesktop
 
         if (frame.getX()<1 && frame.getY()<1)
        {
-         frame.setLocation(xOffset * openFrameCount, yOffset * (openFrameCount%10)+yOffset);
+         frame.setLocation(xOffset * openFrameCount, yOffset * ((openFrameCount-1)%10)+yOffset);
        }
 
-        frame.toFront();
+       desktop.add(frame);
+       try
+       {
+         frame.setSelected(true);
+         frame.toFront();
+       }
+       catch (Exception e)
+       {
+         System.out.println("got it " + e);
+       }
+
+
         final JMenuItem menuItem = new JMenuItem(title);
         frame.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
             {
@@ -209,13 +213,11 @@ public class Desktop extends jalview.jbgui.GDesktop
                     }
                     catch (java.beans.PropertyVetoException ex)
                     {
-                    }
 
-                    ;
+                    }
                 }
             });
 
-        frame.setVisible(true);
         windowMenu.add(menuItem);
     }