+ private static void setLookAndFeel()
+ {
+ // property laf = "crossplatform", "system", "gtk", "metal", "nimbus",
+ // "mac" or "flat"
+ // If not set (or chosen laf fails), use the normal SystemLaF and if on Mac,
+ // try Quaqua/Vaqua.
+ String lafProp = System.getProperty("laf");
+ String lafSetting = Cache.getDefault("PREFERRED_LAF", null);
+ String laf = "none";
+ if (lafProp != null)
+ {
+ laf = lafProp;
+ }
+ else if (lafSetting != null)
+ {
+ laf = lafSetting;
+ }
+ boolean lafSet = false;
+ switch (laf)
+ {
+ case "crossplatform":
+ lafSet = setCrossPlatformLookAndFeel();
+ if (!lafSet)
+ {
+ Console.error("Could not set requested laf=" + laf);
+ }
+ break;
+ case "system":
+ lafSet = setSystemLookAndFeel();
+ if (!lafSet)
+ {
+ Console.error("Could not set requested laf=" + laf);
+ }
+ break;
+ case "gtk":
+ lafSet = setGtkLookAndFeel();
+ if (!lafSet)
+ {
+ Console.error("Could not set requested laf=" + laf);
+ }
+ break;
+ case "metal":
+ lafSet = setMetalLookAndFeel();
+ if (!lafSet)
+ {
+ Console.error("Could not set requested laf=" + laf);
+ }
+ break;
+ case "nimbus":
+ lafSet = setNimbusLookAndFeel();
+ if (!lafSet)
+ {
+ Console.error("Could not set requested laf=" + laf);
+ }
+ break;
+ case "flat":
+ lafSet = setFlatLookAndFeel();
+ if (!lafSet)
+ {
+ Console.error("Could not set requested laf=" + laf);
+ }
+ break;
+ case "mac":
+ lafSet = setMacLookAndFeel();
+ if (!lafSet)
+ {
+ Console.error("Could not set requested laf=" + laf);
+ }
+ break;
+ case "none":
+ break;
+ default:
+ Console.error("Requested laf=" + laf + " not implemented");
+ }
+ if (!lafSet)
+ {
+ // Flatlaf default for everyone!
+ lafSet = setFlatLookAndFeel();
+ if (!lafSet)
+ {
+ setSystemLookAndFeel();
+ }
+ if (Platform.isLinux())
+ {
+ setLinuxLookAndFeel();
+ }
+ if (Platform.isMac())
+ {
+ setMacLookAndFeel();
+ }
+ }
+ }
+
+ private static boolean setCrossPlatformLookAndFeel()
+ {
+ boolean set = false;
+ try
+ {
+ UIManager.setLookAndFeel(
+ UIManager.getCrossPlatformLookAndFeelClassName());
+ set = true;
+ } catch (Exception ex)
+ {
+ Console.error("Unexpected Look and Feel Exception");
+ Console.error(ex.getMessage());
+ Console.debug(Cache.getStackTraceString(ex));
+ }
+ return set;
+ }
+
+ private static boolean setSystemLookAndFeel()
+ {
+ boolean set = false;
+ try
+ {
+ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+ set = true;
+ } catch (Exception ex)
+ {
+ Console.error("Unexpected Look and Feel Exception");
+ Console.error(ex.getMessage());
+ Console.debug(Cache.getStackTraceString(ex));
+ }
+ return set;
+ }
+
+ private static boolean setSpecificLookAndFeel(String name,
+ String className, boolean nameStartsWith)
+ {
+ boolean set = false;
+ try
+ {
+ for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels())
+ {
+ 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)))
+ {
+ className = info.getClassName();
+ break;
+ }
+ }
+ UIManager.setLookAndFeel(className);
+ set = true;
+ } catch (Exception ex)
+ {
+ Console.error("Unexpected Look and Feel Exception");
+ Console.error(ex.getMessage());
+ Console.debug(Cache.getStackTraceString(ex));
+ }
+ return set;
+ }
+
+ private static boolean setGtkLookAndFeel()
+ {
+ return setSpecificLookAndFeel("gtk",
+ "com.sun.java.swing.plaf.gtk.GTKLookAndFeel", true);
+ }
+
+ private static boolean setMetalLookAndFeel()
+ {
+ return setSpecificLookAndFeel("metal",
+ "javax.swing.plaf.metal.MetalLookAndFeel", false);
+ }
+
+ private static boolean setNimbusLookAndFeel()
+ {
+ return setSpecificLookAndFeel("nimbus",
+ "javax.swing.plaf.nimbus.NimbusLookAndFeel", false);
+ }
+
+ private static boolean setFlatLookAndFeel()
+ {
+ boolean set = false;
+ if (SystemInfo.isMacOS)
+ {
+ try
+ {
+ UIManager.setLookAndFeel(
+ "com.formdev.flatlaf.themes.FlatMacLightLaf");
+ set = true;
+ Console.debug("Using FlatMacLightLaf");
+ } catch (ClassNotFoundException | InstantiationException
+ | IllegalAccessException | UnsupportedLookAndFeelException e)
+ {
+ Console.debug("Exception loading FlatLightLaf", e);
+ }
+ 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)
+ {
+ Console.debug("Setting transparent title bar");
+ Desktop.desktop.getRootPane()
+ .putClientProperty("apple.awt.fullWindowContent", true);
+ Desktop.desktop.getRootPane()
+ .putClientProperty("apple.awt.transparentTitleBar", true);
+ Desktop.desktop.getRootPane()
+ .putClientProperty("apple.awt.fullscreenable", true);
+ }
+ SwingUtilities.invokeLater(() -> {
+ FlatMacLightLaf.setup();
+ });
+ Console.debug("Using FlatMacLightLaf");
+ set = true;
+ }
+ if (!set)
+ {
+ try
+ {
+ UIManager.setLookAndFeel("com.formdev.flatlaf.FlatLightLaf");
+ set = true;
+ Console.debug("Using FlatLightLaf");
+ } catch (ClassNotFoundException | InstantiationException
+ | IllegalAccessException | UnsupportedLookAndFeelException e)
+ {
+ Console.debug("Exception loading FlatLightLaf", e);
+ }
+ // Windows specific properties here
+ SwingUtilities.invokeLater(() -> {
+ FlatLightLaf.setup();
+ });
+ Console.debug("Using FlatLightLaf");
+ set = true;
+ }
+ else if (SystemInfo.isLinux)
+ {
+ try
+ {
+ UIManager.setLookAndFeel("com.formdev.flatlaf.FlatLightLaf");
+ set = true;
+ Console.debug("Using FlatLightLaf");
+ } catch (ClassNotFoundException | InstantiationException
+ | IllegalAccessException | UnsupportedLookAndFeelException e)
+ {
+ Console.debug("Exception loading FlatLightLaf", e);
+ }
+ // enable custom window decorations
+ JFrame.setDefaultLookAndFeelDecorated(true);
+ JDialog.setDefaultLookAndFeelDecorated(true);
+ SwingUtilities.invokeLater(() -> {
+ FlatLightLaf.setup();
+ });
+ Console.debug("Using FlatLightLaf");
+ set = true;
+ }
+
+ if (!set)
+ {
+ try
+ {
+ UIManager.setLookAndFeel("com.formdev.flatlaf.FlatLightLaf");
+ set = true;
+ Console.debug("Using FlatLightLaf");
+ } catch (ClassNotFoundException | InstantiationException
+ | IllegalAccessException | UnsupportedLookAndFeelException e)
+ {
+ Console.debug("Exception loading FlatLightLaf", e);
+ }
+ }
+
+ if (set)
+ {
+ UIManager.put("TabbedPane.tabType", "card");
+ UIManager.put("TabbedPane.showTabSeparators", true);
+ UIManager.put("TabbedPane.showContentSeparator", true);
+ UIManager.put("TabbedPane.tabSeparatorsFullHeight", true);
+ UIManager.put("TabbedPane.tabsOverlapBorder", true);
+ UIManager.put("TabbedPane.hasFullBorder", true);
+ UIManager.put("TabbedPane.tabLayoutPolicy", "scroll");
+ UIManager.put("TabbedPane.scrollButtonsPolicy", "asNeeded");
+ UIManager.put("TabbedPane.smoothScrolling", true);
+ UIManager.put("TabbedPane.tabWidthMode", "compact");
+ UIManager.put("TabbedPane.selectedBackground", Color.white);
+ UIManager.put("TabbedPane.background", new Color(236, 236, 236));
+ UIManager.put("TabbedPane.hoverColor", Color.lightGray);
+ }
+
+ Desktop.setLiveDragMode(Cache.getDefault("FLAT_LIVE_DRAG_MODE", true));
+ return set;
+ }
+
+ private static boolean setMacLookAndFeel()
+ {
+ boolean set = false;
+ System.setProperty("com.apple.mrj.application.apple.menu.about.name",
+ ChannelProperties.getProperty("app_name"));
+ System.setProperty("apple.laf.useScreenMenuBar", "true");
+ /*
+ * broken native LAFs on (ARM?) macbooks
+ set = setQuaquaLookAndFeel();
+ if ((!set) || !UIManager.getLookAndFeel().getClass().toString()
+ .toLowerCase(Locale.ROOT).contains("quaqua"))
+ {
+ set = setVaquaLookAndFeel();
+ }
+ */
+ set = setFlatLookAndFeel();
+ return set;
+ }
+
+ private static boolean setLinuxLookAndFeel()
+ {
+ boolean set = false;
+ set = setFlatLookAndFeel();
+ if (!set)
+ set = setMetalLookAndFeel();
+ // avoid GtkLookAndFeel -- not good results especially on HiDPI
+ if (!set)
+ set = setNimbusLookAndFeel();
+ return set;
+ }
+
+ /*