JAL-3416 More explicit setting of FlatLaf macOS theme
authorBen Soares <b.soares@dundee.ac.uk>
Fri, 6 Jan 2023 17:36:42 +0000 (17:36 +0000)
committerBen Soares <b.soares@dundee.ac.uk>
Fri, 6 Jan 2023 17:36:42 +0000 (17:36 +0000)
src/jalview/bin/Jalview.java

index 2fad096..0ec9889 100755 (executable)
@@ -49,6 +49,7 @@ import javax.swing.JOptionPane;
 import javax.swing.SwingUtilities;
 import javax.swing.UIManager;
 import javax.swing.UIManager.LookAndFeelInfo;
+import javax.swing.UnsupportedLookAndFeelException;
 
 import com.formdev.flatlaf.FlatLightLaf;
 import com.formdev.flatlaf.util.SystemInfo;
@@ -1123,9 +1124,29 @@ public class Jalview
 
   private static boolean setFlatLookAndFeel()
   {
-    boolean set = setSpecificLookAndFeel("flatlaf light",
-            Platform.isMac() ? "com.formdev.flatlaf.themes.FlatMacLightLaf" :
-              "com.formdev.flatlaf.FlatLightLaf", false);
+    boolean set = false;
+    if (Platform.isMac()) {
+      try
+      {
+        UIManager.setLookAndFeel("com.formdev.flatlaf.themes.FlatMacLightLaf");
+        set = true;
+      } catch (ClassNotFoundException | InstantiationException
+              | IllegalAccessException | UnsupportedLookAndFeelException e)
+      {
+        Console.debug("Exception loading FlatMacLightLaf", e);
+      }
+    }
+    if (!set) {
+      try
+      {
+        UIManager.setLookAndFeel("com.formdev.flatlaf.FlatLightLaf");
+        set = true;
+      } catch (ClassNotFoundException | InstantiationException
+              | IllegalAccessException | UnsupportedLookAndFeelException e)
+      {
+        Console.debug("Exception loading FlatLightLaf", e);
+      }
+    }
     if (set)
     {
       if (Platform.isMac())