From 1673dc57e85d113ad1286b606adc7e4ecfcf093d Mon Sep 17 00:00:00 2001 From: sk89q Date: Sat, 14 Nov 2015 16:22:20 -0800 Subject: [PATCH] Select nearest entry on right click of instance list. --- .../java/com/skcraft/launcher/dialog/LauncherFrame.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/launcher/src/main/java/com/skcraft/launcher/dialog/LauncherFrame.java b/launcher/src/main/java/com/skcraft/launcher/dialog/LauncherFrame.java index 79f287d..75ed9a0 100644 --- a/launcher/src/main/java/com/skcraft/launcher/dialog/LauncherFrame.java +++ b/launcher/src/main/java/com/skcraft/launcher/dialog/LauncherFrame.java @@ -154,9 +154,14 @@ public class LauncherFrame extends JFrame { @Override protected void showPopup(MouseEvent e) { //noinspection unchecked - Instance selected = ((JList) e.getSource()).getSelectedValue(); - if (selected != null) { + JList list = ((JList) e.getSource()); + int index = list.locationToIndex(new Point(e.getX(), e.getY())); + if (index >= 0) { + list.setSelectedIndex(list.locationToIndex(new Point(e.getX(), e.getY()))); + Instance selected = list.getSelectedValue(); popupInstanceMenu(e.getComponent(), e.getX(), e.getY(), selected); + } else { + list.setSelectedValue(null, false); } } });