From a91f5e1edbc1cfc6358738c2e739b1ff0d7651b5 Mon Sep 17 00:00:00 2001 From: Matt Jenkins Date: Fri, 28 Sep 2018 11:20:24 +0100 Subject: [PATCH] Added double-click support to open dialog --- .../audiobookrecorder/OpenBookPanel.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/uk/co/majenko/audiobookrecorder/OpenBookPanel.java b/src/uk/co/majenko/audiobookrecorder/OpenBookPanel.java index 5e5047e..8bcc007 100644 --- a/src/uk/co/majenko/audiobookrecorder/OpenBookPanel.java +++ b/src/uk/co/majenko/audiobookrecorder/OpenBookPanel.java @@ -100,11 +100,33 @@ public class OpenBookPanel extends JPanel { table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setRowHeight(80); table.getTableHeader().setUI(null); + + table.addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent e) { + if (e.getClickCount() == 2 && table.getSelectedRow() != -1) { + Component c = (Component)OpenBookPanel.this; + while ((c != null) && (!(c instanceof JOptionPane))) { + c = c.getParent(); + } + if (c == null) { + System.err.println("Could not get option pane!"); + } else { + JOptionPane op = (JOptionPane)c; + op.setValue(JOptionPane.OK_OPTION); + } + } + } + }); + + + + scroll.setViewportView(table); } catch (Exception e) { e.printStackTrace(); } + } public File getSelectedFile() {