Mouse Click Events on JTable -Java : I want to get the Index of Selected row when user double clicks on a row.

here is my code

    tab.addMouseListener(new MouseAdapter() {
			        public void mouseClicked(MouseEvent e) {
			            if (e.getClickCount() == 2) {
			            	
			                int selectedRow = tab.getSelectedRow();
			               
			                try {
			                  String file=rows[selectedRow][2];
			                  String path="C:\\Users\\raj kumar\\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();
			                    }
			                }
			            }
			        });

But the tab.getSelectedRow() return -1 eventhough i double clicked the row in table.
ThankYou.