Added double-click support to open dialog

This commit is contained in:
2018-09-28 11:20:24 +01:00
parent 9e42cfa8db
commit a91f5e1edb

View File

@@ -100,11 +100,33 @@ public class OpenBookPanel extends JPanel {
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.setRowHeight(80); table.setRowHeight(80);
table.getTableHeader().setUI(null); 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); scroll.setViewportView(table);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
public File getSelectedFile() { public File getSelectedFile() {