1
0
mirror of https://github.com/SKCraft/Launcher.git synced 2024-11-27 12:46:22 +01:00

Select nearest entry on right click of instance list.

This commit is contained in:
sk89q 2015-11-14 16:22:20 -08:00
parent 991d39ced6
commit 1673dc57e8

View File

@ -154,9 +154,14 @@ public class LauncherFrame extends JFrame {
@Override
protected void showPopup(MouseEvent e) {
//noinspection unchecked
Instance selected = ((JList<Instance>) e.getSource()).getSelectedValue();
if (selected != null) {
JList<Instance> list = ((JList<Instance>) 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);
}
}
});