JAL-4055 quick patch to see how Jalview looks as a free-floating multiwindowed app...
[jalview.git] / src / jalview / gui / Desktop.java
index aeb0fac..9681198 100644 (file)
@@ -20,8 +20,6 @@
  */
 package jalview.gui;
 
-import java.util.Locale;
-
 import java.awt.BorderLayout;
 import java.awt.Color;
 import java.awt.Dimension;
@@ -64,6 +62,7 @@ import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.List;
 import java.util.ListIterator;
+import java.util.Locale;
 import java.util.Vector;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -82,6 +81,7 @@ import javax.swing.JCheckBox;
 import javax.swing.JComboBox;
 import javax.swing.JComponent;
 import javax.swing.JDesktopPane;
+import javax.swing.JFrame;
 import javax.swing.JInternalFrame;
 import javax.swing.JLabel;
 import javax.swing.JMenuItem;
@@ -183,7 +183,7 @@ public class Desktop extends jalview.jbgui.GDesktop
 
   private static final String EXPERIMENTAL_FEATURES = "EXPERIMENTAL_FEATURES";
 
-  protected static final String CONFIRM_KEYBOARD_QUIT = "CONFIRM_KEYBOARD_QUIT";
+  public static final String CONFIRM_KEYBOARD_QUIT = "CONFIRM_KEYBOARD_QUIT";
 
   public static HashMap<String, FileWriter> savingFiles = new HashMap<String, FileWriter>();
 
@@ -444,24 +444,6 @@ public class Desktop extends jalview.jbgui.GDesktop
       }
     }
 
-    /**
-     * APQHandlers sets handlers for About, Preferences and Quit actions
-     * peculiar to macOS's application menu. APQHandlers will check to see if a
-     * handler is supported before setting it.
-     */
-    try
-    {
-      APQHandlers.setAPQHandlers(this);
-    } catch (Exception e)
-    {
-      System.out.println("Cannot set APQHandlers");
-      // e.printStackTrace();
-    } catch (Throwable t)
-    {
-      jalview.bin.Console
-              .warn("Error setting APQHandlers: " + t.toString());
-      jalview.bin.Console.trace(Cache.getStackTraceString(t));
-    }
     setIconImages(ChannelProperties.getIconList());
 
     addWindowListener(new WindowAdapter()
@@ -909,15 +891,17 @@ public class Desktop extends jalview.jbgui.GDesktop
           int w, int h, boolean resizable, boolean ignoreMinSize)
   {
 
+    JFrame extFrame = new JFrame();
+    extFrame.setContentPane(frame);
     // TODO: allow callers to determine X and Y position of frame (eg. via
     // bounds object).
     // TODO: consider fixing method to update entries in the window submenu with
     // the current window title
 
-    frame.setTitle(title);
-    if (frame.getWidth() < 1 || frame.getHeight() < 1)
+    extFrame.setTitle(title);
+    if (extFrame.getWidth() < 1 || extFrame.getHeight() < 1)
     {
-      frame.setSize(w, h);
+      extFrame.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
@@ -933,7 +917,7 @@ public class Desktop extends jalview.jbgui.GDesktop
 
     if (!ignoreMinSize)
     {
-      frame.setMinimumSize(
+      extFrame.setMinimumSize(
               new Dimension(DEFAULT_MIN_WIDTH, DEFAULT_MIN_HEIGHT));
 
       // Set default dimension for Alignment Frame window.
@@ -942,7 +926,7 @@ public class Desktop extends jalview.jbgui.GDesktop
       // I did this here in order not to miss out on any Alignment frame.
       if (frame instanceof AlignFrame)
       {
-        frame.setMinimumSize(new Dimension(ALIGN_FRAME_DEFAULT_MIN_WIDTH,
+        extFrame.setMinimumSize(new Dimension(ALIGN_FRAME_DEFAULT_MIN_WIDTH,
                 ALIGN_FRAME_DEFAULT_MIN_HEIGHT));
       }
     }
@@ -1023,17 +1007,16 @@ public class Desktop extends jalview.jbgui.GDesktop
 
     setKeyBindings(frame);
 
-    desktop.add(frame);
+    // desktop.add(frame);
 
     windowMenu.add(menuItem);
 
-    frame.toFront();
+    extFrame.pack();
+    extFrame.setVisible(true);
+    extFrame.toFront();
     try
     {
-      frame.setSelected(true);
-      frame.requestFocus();
-    } catch (java.beans.PropertyVetoException ve)
-    {
+      extFrame.requestFocus();
     } catch (java.lang.ClassCastException cex)
     {
       jalview.bin.Console.warn(