I am trying to open the image file whenever user double clicks on the selected row. I tried this code but its not working.
tab = new JTable(rows, column);
tab.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
tab.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
int selectedRow = tab.getSelectedRow();
try {
String file = rows[0][2];
String path = "C:\\XX\\YYY\\Gallery\\" + file;
JLabel fileLable = new JLabel();
fileLable.setBounds(500, 600, 300, 300);
fileLable.setIcon(new ImageIcon(path));
pan.add(fileLable);
} catch (Exception e1) {
e1.printStackTrace();
}
}
}
});