use system look and feel

This commit is contained in:
Glavo 2021-09-02 22:09:07 +08:00 committed by Yuhui Huang
parent 243c9b83b9
commit cb49700ded

View File

@ -50,6 +50,11 @@ public final class Main {
System.setProperty("java.net.useSystemProxies", "true"); System.setProperty("java.net.useSystemProxies", "true");
System.setProperty("http.agent", "HMCL/" + Metadata.VERSION); System.setProperty("http.agent", "HMCL/" + Metadata.VERSION);
System.setProperty("javafx.autoproxy.disable", "true"); 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(); checkDirectoryPath();
@ -63,12 +68,19 @@ public final class Main {
checkJavaFX(); checkJavaFX();
// Fix title bar not displaying in GTK systems
System.setProperty("jdk.gtk.version", "2");
Launcher.main(args); 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() { private static void checkDirectoryPath() {
String currentDirectory = new File("").getAbsolutePath(); String currentDirectory = new File("").getAbsolutePath();
if (currentDirectory.contains("!")) { if (currentDirectory.contains("!")) {