From 50ca4826d4a4ec2237d032c5f608edd91a71b44a Mon Sep 17 00:00:00 2001 From: Joacim Breiler Date: Fri, 8 Dec 2023 19:34:42 +0100 Subject: [PATCH] Fixed problem with the default LaF on MacOSX (#2384) Now uses AquaLookAndFeel and disable FlatLaFLight as it doesn't work on MacOSX --- .../core/lifecycle/LookAndFeelInstaller.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/ugs-platform/ugs-platform-ugscore/src/main/java/com/willwinder/ugs/nbp/core/lifecycle/LookAndFeelInstaller.java b/ugs-platform/ugs-platform-ugscore/src/main/java/com/willwinder/ugs/nbp/core/lifecycle/LookAndFeelInstaller.java index a582aea449..fe1a5e9ab3 100644 --- a/ugs-platform/ugs-platform-ugscore/src/main/java/com/willwinder/ugs/nbp/core/lifecycle/LookAndFeelInstaller.java +++ b/ugs-platform/ugs-platform-ugscore/src/main/java/com/willwinder/ugs/nbp/core/lifecycle/LookAndFeelInstaller.java @@ -18,6 +18,7 @@ This file is part of Universal Gcode Sender (UGS). */ package com.willwinder.ugs.nbp.core.lifecycle; +import org.apache.commons.lang3.SystemUtils; import org.openide.modules.ModuleInstall; import org.openide.util.NbPreferences; @@ -30,9 +31,26 @@ public class LookAndFeelInstaller extends ModuleInstall { @Override public void validate() { + if (SystemUtils.IS_OS_MAC_OSX) { + // FlatlLaf look and feel doesn't work on MacOSXs + setMacOSLaF(); + } else { + setLaF(); + } + } + + private void setLaF() { Preferences prefs = NbPreferences.root().node("laf"); if (prefs.get("laf", "").isBlank()) { prefs.put("laf", "com.formdev.flatlaf.FlatLightLaf"); } } -} \ No newline at end of file + + private void setMacOSLaF() { + Preferences prefs = NbPreferences.root().node("laf"); + String currentLaF = prefs.get("laf", ""); + if (currentLaF.isBlank() || currentLaF.equals("com.formdev.flatlaf.FlatLightLaf")) { + prefs.put("laf", "com.apple.laf.AquaLookAndFeel"); + } + } +}