From ddd5934ae1b972d3959f444c6a48d7169709c0ea Mon Sep 17 00:00:00 2001 From: Nathan Cannon Date: Wed, 9 Mar 2016 02:30:38 +0000 Subject: [PATCH] Program will now still run if global keyboard hooks fail to initialise. --- pom.xml | 2 +- src/main/java/musicplayer/PlayerGUI.java | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 72ee09e..656248f 100644 --- a/pom.xml +++ b/pom.xml @@ -88,7 +88,7 @@ lc.kra.system system-hook - 2.1 + 2.2 diff --git a/src/main/java/musicplayer/PlayerGUI.java b/src/main/java/musicplayer/PlayerGUI.java index 6ec0160..4d51bbe 100644 --- a/src/main/java/musicplayer/PlayerGUI.java +++ b/src/main/java/musicplayer/PlayerGUI.java @@ -60,8 +60,14 @@ public class PlayerGUI implements PlayerCallbackInterface, LibraryCallbackInterf } }, "seekbar"); seekBarUpdater.start(); - GlobalKeyboardHook keyboardHook = new GlobalKeyboardHook(); - keyboardHook.addKeyListener(new GlobalKeyboardShortcuts()); + try { + GlobalKeyboardHook keyboardHook = new GlobalKeyboardHook(); + keyboardHook.addKeyListener(new GlobalKeyboardShortcuts()); + } catch(RuntimeException ex){ + System.out.println("Keyboard hook failed, global shortcuts will not work this session."); + System.out.println(ex.getMessage()); + System.out.println(Arrays.toString(ex.getStackTrace())); + } refreshLibrary(); }