From c4c08d98b62dda2ae3f182dd837483a20a0a3a98 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Mon, 17 Oct 2016 03:11:49 +0800 Subject: [PATCH] Refactor LaF methods --- source/net/filebot/Main.java | 9 ++++----- source/net/filebot/util/ui/SwingUI.java | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/source/net/filebot/Main.java b/source/net/filebot/Main.java index 6aeed4c5..d2253f2d 100644 --- a/source/net/filebot/Main.java +++ b/source/net/filebot/Main.java @@ -35,7 +35,6 @@ import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.SwingUtilities; -import javax.swing.UIManager; import org.kohsuke.args4j.CmdLineException; import org.w3c.dom.Document; @@ -186,10 +185,10 @@ public class Main { private static void startUserInterface(ArgumentBean args) { // use native LaF an all platforms (use platform-independent laf for standalone jar deployment) - try { - UIManager.setLookAndFeel(isExecutableJar() ? "javax.swing.plaf.nimbus.NimbusLookAndFeel" : UIManager.getSystemLookAndFeelClassName()); - } catch (Exception e) { - debug.log(Level.SEVERE, e.getMessage(), e); + if (isExecutableJar()) { + setNimbusLookAndFeel(); + } else { + setSystemLookAndFeel(); } // default frame diff --git a/source/net/filebot/util/ui/SwingUI.java b/source/net/filebot/util/ui/SwingUI.java index d48bcbd8..46d41933 100644 --- a/source/net/filebot/util/ui/SwingUI.java +++ b/source/net/filebot/util/ui/SwingUI.java @@ -45,6 +45,7 @@ import javax.swing.SwingConstants; import javax.swing.SwingUtilities; import javax.swing.SwingWorker; import javax.swing.Timer; +import javax.swing.UIManager; import javax.swing.event.MouseInputListener; import javax.swing.plaf.basic.BasicTableUI; import javax.swing.text.JTextComponent; @@ -56,6 +57,22 @@ import net.filebot.Settings; public final class SwingUI { + public static void setNimbusLookAndFeel() { + try { + UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel"); + } catch (Exception e) { + debug.log(Level.SEVERE, "Failed to set Nimbus LaF", e); + } + } + + public static void setSystemLookAndFeel() { + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } catch (Exception e) { + debug.log(Level.SEVERE, "Failed to set System LaF", e); + } + } + public static void openURI(String uri) { try { Desktop.getDesktop().browse(URI.create(uri));