From 36cc0da30602efd238236acd0aec376137759010 Mon Sep 17 00:00:00 2001 From: Nathan Cannon Date: Mon, 7 Mar 2016 16:05:35 +0000 Subject: [PATCH] Restricted library to playlist functionality to left clicks. --- src/main/java/musicplayer/PlayerGUI.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/main/java/musicplayer/PlayerGUI.java b/src/main/java/musicplayer/PlayerGUI.java index 65dfde4..b932eac 100644 --- a/src/main/java/musicplayer/PlayerGUI.java +++ b/src/main/java/musicplayer/PlayerGUI.java @@ -426,18 +426,15 @@ public class PlayerGUI implements PlayerCallbackInterface, LibraryCallbackInterf @Override public void mousePressed(MouseEvent e) { int selRow = libraryView.getRowForLocation(e.getX(), e.getY()); + if(e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2 && selRow != -1) try { Object selectedItem = ((DefaultMutableTreeNode) libraryView.getPathForLocation(e.getX(), e.getY()).getLastPathComponent()).getUserObject(); - if (selRow != -1) { - if (e.getClickCount() == 2) { - if (selectedItem != null) { - if (selectedItem instanceof Song) { - addToPlaylist((Song) selectedItem); - } else if (selectedItem instanceof Album) { - ((Album) selectedItem).getSongs().forEach(PlayerGUI.this::addToPlaylist); - } + if (selectedItem != null) { + if (selectedItem instanceof Song) { + addToPlaylist((Song) selectedItem); + } else if (selectedItem instanceof Album) { + ((Album) selectedItem).getSongs().forEach(PlayerGUI.this::addToPlaylist); } - } } } catch (NullPointerException ignored) { }