From ab6ec9ed71d62861bb40c2d16713145b2d21d8b8 Mon Sep 17 00:00:00 2001 From: sk89q Date: Thu, 19 Feb 2015 03:13:07 -0800 Subject: [PATCH] Add a fancy skinned version of the launcher. --- launcher-fancy/build.gradle | 20 +++++++++++++++++++ .../com/skcraft/launcher/FancyLauncher.java | 17 ++++++++++++++++ .../java/com/skcraft/launcher/Launcher.java | 13 +++++++++++- settings.gradle | 2 +- 4 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 launcher-fancy/build.gradle create mode 100644 launcher-fancy/src/main/java/com/skcraft/launcher/FancyLauncher.java diff --git a/launcher-fancy/build.gradle b/launcher-fancy/build.gradle new file mode 100644 index 0000000..ef091f8 --- /dev/null +++ b/launcher-fancy/build.gradle @@ -0,0 +1,20 @@ +apply plugin: 'com.github.johnrengelman.shadow' + +jar { + manifest { + attributes("Main-Class": "com.skcraft.launcher.FancyLauncher") + } +} + +dependencies { + compile project(':launcher') + compile 'com.github.insubstantial:substance:7.3' +} + +shadowJar { + dependencies { + exclude(dependency('org.projectlombok:lombok')) + } +} + +build.dependsOn(shadowJar) \ No newline at end of file diff --git a/launcher-fancy/src/main/java/com/skcraft/launcher/FancyLauncher.java b/launcher-fancy/src/main/java/com/skcraft/launcher/FancyLauncher.java new file mode 100644 index 0000000..e4bdbbf --- /dev/null +++ b/launcher-fancy/src/main/java/com/skcraft/launcher/FancyLauncher.java @@ -0,0 +1,17 @@ +package com.skcraft.launcher; + +import javax.swing.*; + +public class FancyLauncher { + + public static void main(String[] args) { + UIManager.getLookAndFeelDefaults().put("ClassLoader", FancyLauncher.class.getClassLoader()); + JFrame.setDefaultLookAndFeelDecorated(true); + JDialog.setDefaultLookAndFeelDecorated(true); + System.setProperty("sun.awt.noerasebackground", "true"); + System.setProperty("substancelaf.windowRoundedCorners", "false"); + System.setProperty("com.skcraft.launcher.laf", "org.pushingpixels.substance.api.skin.SubstanceMarinerLookAndFeel"); + Launcher.main(args); + } + +} diff --git a/launcher/src/main/java/com/skcraft/launcher/Launcher.java b/launcher/src/main/java/com/skcraft/launcher/Launcher.java index 3a3750e..a54ad52 100644 --- a/launcher/src/main/java/com/skcraft/launcher/Launcher.java +++ b/launcher/src/main/java/com/skcraft/launcher/Launcher.java @@ -349,7 +349,18 @@ public final class Launcher { @Override public void run() { try { - UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + String lafName = System.getProperty("com.skcraft.launcher.laf"); + if (lafName != null) { + try { + UIManager.setLookAndFeel(lafName); + } catch (Exception e) { + log.log(Level.WARNING, "Failed to set look and feel to " + lafName, e); + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } + } else { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } + UIManager.getDefaults().put("SplitPane.border", BorderFactory.createEmptyBorder()); Launcher launcher = new Launcher(baseDir); new LauncherFrame(launcher).setVisible(true); diff --git a/settings.gradle b/settings.gradle index 2cff48c..308838d 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,3 +1,3 @@ rootProject.name = 'launcher-parent' -include 'launcher', 'launcher-builder' \ No newline at end of file +include 'launcher', 'launcher-fancy', 'launcher-builder' \ No newline at end of file