desktop = null;
- try
- {
- UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
- } catch (Exception ex)
- {
- System.err.println("Unexpected Look and Feel Exception");
- ex.printStackTrace();
- }
- if (Platform.isAMacAndNotJS())
- {
-
- LookAndFeel lookAndFeel = ch.randelshofer.quaqua.QuaquaManager
- .getLookAndFeel();
- System.setProperty("com.apple.mrj.application.apple.menu.about.name",
- "Jalview");
- System.setProperty("apple.laf.useScreenMenuBar", "true");
- if (lookAndFeel != null)
+ // property laf = "crossplatform", "system" or "mac"
+ // If not set (or chosen laf fails), use the normal SystemLaF and if on Mac, try Quaqua/Vaqua.
+ String laf = System.getProperty("laf","none");
+ boolean lafSet = false;
+ switch(laf) {
+ case "crossplatform":
+ lafSet = setCrossPlatformLookAndFeel();
+ if (!lafSet)
{
- try
- {
- UIManager.setLookAndFeel(lookAndFeel);
- } catch (Throwable e)
- {
- System.err.println(
- "Failed to set QuaQua look and feel: " + e.toString());
- }
+ System.err.println("Could not set requested laf="+laf);
}
- if (lookAndFeel == null
- || !(lookAndFeel.getClass().isAssignableFrom(
- UIManager.getLookAndFeel().getClass()))
- || !UIManager.getLookAndFeel().getClass().toString()
- .toLowerCase().contains("quaqua"))
+ break;
+ case "system":
+ lafSet = setSystemLookAndFeel();
+ if (!lafSet)
{
- try
- {
- System.err.println(
- "Quaqua LaF not available on this plaform. Using VAqua(4).\nSee https://issues.jalview.org/browse/JAL-2976");
- UIManager.setLookAndFeel("org.violetlib.aqua.AquaLookAndFeel");
- } catch (Throwable e)
- {
- System.err.println(
- "Failed to reset look and feel: " + e.toString());
- }
+ System.err.println("Could not set requested laf="+laf);
+ }
+ break;
+ case "mac":
+ lafSet = setMacLookAndFeel();
+ if (!lafSet)
+ {
+ System.err.println("Could not set requested laf="+laf);
+ }
+ break;
+ case "none":
+ break;
+ default:
+ System.err.println("Requested laf="+laf+" not implemented");
+ }
+ if (! lafSet)
+ {
+ setSystemLookAndFeel();
+ if (Platform.isAMacAndNotJS())
+ {
+ setMacLookAndFeel();
}
}
}
}
+ private static boolean setCrossPlatformLookAndFeel() {
+ boolean set = false;
+ try
+ {
+ UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
+ set = true;
+ } catch (Exception ex)
+ {
+ System.err.println("Unexpected Look and Feel Exception");
+ ex.printStackTrace();
+ }
+ return set;
+ }
+
+ private static boolean setSystemLookAndFeel() {
+ boolean set = false;
+ try
+ {
+ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+ set = true;
+ } catch (Exception ex)
+ {
+ System.err.println("Unexpected Look and Feel Exception");
+ ex.printStackTrace();
+ }
+ return set;
+ }
+
+ private static boolean setMacLookAndFeel() {
+ boolean set = false;
+ LookAndFeel lookAndFeel = ch.randelshofer.quaqua.QuaquaManager
+ .getLookAndFeel();
+ System.setProperty("com.apple.mrj.application.apple.menu.about.name",
+ "Jalview");
+ System.setProperty("apple.laf.useScreenMenuBar", "true");
+ if (lookAndFeel != null)
+ {
+ try
+ {
+ UIManager.setLookAndFeel(lookAndFeel);
+ set = true;
+ } catch (Throwable e)
+ {
+ System.err.println(
+ "Failed to set QuaQua look and feel: " + e.toString());
+ }
+ }
+ if (lookAndFeel == null
+ || !(lookAndFeel.getClass().isAssignableFrom(
+ UIManager.getLookAndFeel().getClass()))
+ || !UIManager.getLookAndFeel().getClass().toString()
+ .toLowerCase().contains("quaqua"))
+ {
+ try
+ {
+ System.err.println(
+ "Quaqua LaF not available on this plaform. Using VAqua(4).\nSee https://issues.jalview.org/browse/JAL-2976");
+ UIManager.setLookAndFeel("org.violetlib.aqua.AquaLookAndFeel");
+ set = true;
+ } catch (Throwable e)
+ {
+ System.err.println(
+ "Failed to reset look and feel: " + e.toString());
+ }
+ }
+ return set;
+ }
+
private static void showUsage()
{
System.out.println(