JAL-3416 Added some mac specific FlatLAF settings. Note this is not the default...
authorBen Soares <bsoares@dundee.ac.uk>
Mon, 13 Jun 2022 10:18:31 +0000 (11:18 +0100)
committerBen Soares <bsoares@dundee.ac.uk>
Mon, 13 Jun 2022 10:18:31 +0000 (11:18 +0100)
src/jalview/bin/Jalview.java

index f4d340b..c0559db 100755 (executable)
@@ -45,9 +45,12 @@ import java.util.logging.ConsoleHandler;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import javax.swing.SwingUtilities;
 import javax.swing.UIManager;
 import javax.swing.UIManager.LookAndFeelInfo;
 
+import com.formdev.flatlaf.FlatLightLaf;
+import com.formdev.flatlaf.util.SystemInfo;
 import com.threerings.getdown.util.LaunchUtil;
 
 import groovy.lang.Binding;
@@ -791,8 +794,8 @@ public class Jalview
               jalview.bin.Cache.getDefault("www.jalview.org",
                       "https://www.jalview.org")
                       + "/examples/exampleFile_2_7.jvp");
-      if (file.equals(
-              "http://www.jalview.org/examples/exampleFile_2_3.jar") || file.equals(
+      if (file.equals("http://www.jalview.org/examples/exampleFile_2_3.jar")
+              || file.equals(
                       "http://www.jalview.org/examples/exampleFile_2_7.jar"))
       {
         file.replace("http:", "https:");
@@ -997,7 +1000,8 @@ public class Jalview
         if (info.getName() != null && nameStartsWith
                 ? info.getName().toLowerCase(Locale.ROOT)
                         .startsWith(name.toLowerCase(Locale.ROOT))
-                : info.getName().toLowerCase(Locale.ROOT).equals(name.toLowerCase(Locale.ROOT)))
+                : info.getName().toLowerCase(Locale.ROOT)
+                        .equals(name.toLowerCase(Locale.ROOT)))
         {
           className = info.getClassName();
           break;
@@ -1038,10 +1042,30 @@ public class Jalview
             "com.formdev.flatlaf.FlatLightLaf", false);
     if (set)
     {
+      if (Platform.isMac())
+      {
+        System.setProperty("apple.laf.useScreenMenuBar", "true");
+        System.setProperty("apple.awt.application.name",
+                ChannelProperties.getProperty("app_name"));
+        System.setProperty("apple.awt.application.appearance", "system");
+        if (SystemInfo.isMacFullWindowContentSupported
+                && Desktop.desktop != null)
+        {
+          Desktop.desktop.getRootPane()
+                  .putClientProperty("apple.awt.fullWindowContent", true);
+          Desktop.desktop.getRootPane()
+                  .putClientProperty("apple.awt.transparentTitleBar", true);
+        }
+
+        SwingUtilities.invokeLater(() -> {
+          FlatLightLaf.setup();
+        });
+      }
+
       UIManager.put("TabbedPane.showTabSeparators", true);
       UIManager.put("TabbedPane.tabSeparatorsFullHeight", true);
       UIManager.put("TabbedPane.tabsOverlapBorder", true);
-      //UIManager.put("TabbedPane.hasFullBorder", true);
+      // UIManager.put("TabbedPane.hasFullBorder", true);
       UIManager.put("TabbedPane.tabLayoutPolicy", "scroll");
       UIManager.put("TabbedPane.scrollButtonsPolicy", "asNeeded");
       UIManager.put("TabbedPane.smoothScrolling", true);