From c7231a572a430751ecc38cab3aa29ea7c60e9d92 Mon Sep 17 00:00:00 2001 From: loveb Date: Wed, 30 Mar 2022 16:07:24 +0200 Subject: [PATCH] Only embed if supported --- src/schack/Schack.java | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/schack/Schack.java b/src/schack/Schack.java index 7817d0f..750b7e8 100644 --- a/src/schack/Schack.java +++ b/src/schack/Schack.java @@ -23,7 +23,8 @@ public class Schack { try { // FlatSolarizedLightIJTheme.setup(); FlatLightLaf.setup(); - System.setProperty("flatlaf.menuBarEmbedded", "true"); + embedMenuBarIfSupported(); + } catch (Exception cantThemeWithFlatLaf) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); @@ -85,7 +86,22 @@ public class Schack { public static void main(String[] args) throws IOException { new Schack(); -new Schack(); + } + + private void embedMenuBarIfSupported() { + // Currently only supported in Windows 10+ + String os = System.getProperty("os.name"); + if (os.contains("Windows")) { + String versionNumberStr = os.split(" ")[1]; + try { + int versionNumber = Integer.parseInt(versionNumberStr); + if (versionNumber >= 10) { + System.setProperty("flatlaf.menuBarEmbedded", "true"); + } + } catch (Exception e) { + } + + } } }