From cb49700dedce3ccc40d5caff169a1e2e6fc57d4b Mon Sep 17 00:00:00 2001 From: Glavo Date: Thu, 2 Sep 2021 22:09:07 +0800 Subject: [PATCH] use system look and feel --- HMCL/src/main/java/org/jackhuang/hmcl/Main.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/Main.java b/HMCL/src/main/java/org/jackhuang/hmcl/Main.java index 9a82d1799..0be26ce20 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/Main.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/Main.java @@ -50,6 +50,11 @@ public final class Main { System.setProperty("java.net.useSystemProxies", "true"); System.setProperty("http.agent", "HMCL/" + Metadata.VERSION); System.setProperty("javafx.autoproxy.disable", "true"); + // Fix title bar not displaying in GTK systems + System.setProperty("jdk.gtk.version", "2"); + + // Use System look and feel + initLookAndFeel(); checkDirectoryPath(); @@ -63,12 +68,19 @@ public final class Main { checkJavaFX(); - // Fix title bar not displaying in GTK systems - System.setProperty("jdk.gtk.version", "2"); Launcher.main(args); } + private static void initLookAndFeel() { + if (System.getProperty("swing.defaultlaf") == null) { + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } catch (Throwable ignored) { + } + } + } + private static void checkDirectoryPath() { String currentDirectory = new File("").getAbsolutePath(); if (currentDirectory.contains("!")) {