Dont setSelected on new frames
[jalview.git] / src / jalview / gui / Desktop.java
index 498a6e6..97c6a20 100755 (executable)
@@ -113,10 +113,12 @@ public class Desktop extends jalview.jbgui.GDesktop
         SplashScreen splash = new SplashScreen(frame, image);
         frame.setContentPane(splash);
         frame.setLayer(JLayeredPane.PALETTE_LAYER);
-        addInternalFrame(frame, "", 750, 160, false);
         frame.setLocation((int) ((getWidth() - 750) / 2),
             (int) ((getHeight() - 160) / 2));
-      discoverer=new jalview.ws.Discoverer(); // Only gets started if gui is displayed.
+
+        addInternalFrame(frame, "", 750, 160, false);
+
+        discoverer=new jalview.ws.Discoverer(); // Only gets started if gui is displayed.
     }
 
     /**
@@ -127,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);
@@ -142,15 +144,15 @@ 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)
     {
 
       frame.setTitle(title);
-      if(w!=AlignFrame.NEW_WINDOW_WIDTH &&
-        h!=AlignFrame.NEW_WINDOW_HEIGHT)
-       frame.setSize(w, h);
-
+      if(frame.getWidth()<1 || frame.getHeight()<1)
+      {
+        frame.setSize(w, h);
+      }
       // THIS IS A PUBLIC STATIC METHOD, SO IT MAY BE CALLED EVEN IN
       // A HEADLESS STATE WHEN NO DESKTOP EXISTS. MUST RETURN
       // IF JALVIEW IS RUNNING HEADLESS
@@ -162,26 +164,23 @@ 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);
         frame.setIconifiable(resizable);
         frame.setFrameIcon(null);
-        if (w != AlignFrame.NEW_WINDOW_WIDTH &&
-            h != AlignFrame.NEW_WINDOW_HEIGHT)
-          frame.setLocation(xOffset * openFrameCount, yOffset * openFrameCount);
-        frame.toFront();
+
+        if (frame.getX()<1 && frame.getY()<1)
+       {
+         frame.setLocation(xOffset * openFrameCount, yOffset * ((openFrameCount-1)%10)+yOffset);
+       }
+
+       desktop.add(frame);
+       frame.toFront();
+
 
         final JMenuItem menuItem = new JMenuItem(title);
         frame.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
@@ -206,13 +205,11 @@ public class Desktop extends jalview.jbgui.GDesktop
                     }
                     catch (java.beans.PropertyVetoException ex)
                     {
-                    }
 
-                    ;
+                    }
                 }
             });
 
-        frame.setVisible(true);
         windowMenu.add(menuItem);
     }