JAL-3608 Added java builtin NimbusLookAndFeel option 'nimbus'
authorBen Soares <bsoares@dundee.ac.uk>
Fri, 1 May 2020 10:57:37 +0000 (11:57 +0100)
committerBen Soares <bsoares@dundee.ac.uk>
Fri, 1 May 2020 10:57:37 +0000 (11:57 +0100)
src/jalview/bin/Jalview.java

index cc3a4a2..992ca01 100755 (executable)
@@ -45,6 +45,7 @@ import java.util.logging.Logger;
 
 import javax.swing.LookAndFeel;
 import javax.swing.UIManager;
+import javax.swing.UIManager.LookAndFeelInfo;
 
 import com.threerings.getdown.util.LaunchUtil;
 
@@ -400,6 +401,12 @@ public class Jalview
         System.err.println("Could not set requested laf=" + laf);
       }
       break;
+    case "nimbus":
+      lafSet = setNimbusLookAndFeel();
+      {
+        System.err.println("Could not set requested laf=" + laf);
+      }
+      break;
     case "mac":
       lafSet = setMacLookAndFeel();
       if (!lafSet)
@@ -899,6 +906,12 @@ public class Jalview
     String laf = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
     try
     {
+      for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
+        if (info.getName() != null && info.getName().startsWith("Gtk")) {
+          laf = info.getClassName();
+          break;
+        }
+      }
       UIManager.setLookAndFeel(laf);
       set = true;
     } catch (Exception ex)
@@ -915,6 +928,34 @@ public class Jalview
     String laf = "javax.swing.plaf.metal.MetalLookAndFeel";
     try
     {
+      for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
+        if (info.getName() != null && info.getName().equals("Metal")) {
+          laf = info.getClassName();
+          break;
+        }
+      }
+      UIManager.setLookAndFeel(laf);
+      set = true;
+    } catch (Exception ex)
+    {
+      System.err.println("Unexpected Look and Feel Exception");
+      ex.printStackTrace();
+    }
+    return set;
+  }
+
+  private static boolean setNimbusLookAndFeel()
+  {
+    boolean set = false;
+    String laf = "javax.swing.plaf.nimbus.NimbusLookAndFeel";
+    try
+    {
+      for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
+        if (info.getName() != null && info.getName().equals("Nimbus")) {
+          laf = info.getClassName();
+          break;
+        }
+      }
       UIManager.setLookAndFeel(laf);
       set = true;
     } catch (Exception ex)