JTable and mouseclicks...
843805Sep 26 2005 — edited Feb 6 2006I am new to Java and JFC, and I am trying to make a program that uses a table (JTable) to display some data.
I am trying to make a response to "double-clicks" on the table and I have added a mouse listener which calls MouseEvent.getClickCount() to check the number of clicks. But no matter how many times I click
MouseEvent.getClickCount() always returns 1.
The code for my mouseListener is below.
If I try with a different number in the if-condition (ie. clickCount==2) the dialog wil not show. clickCount is always set to 1 even if I double-click or not...
What could be wrong?
public class TabellMusBehandler implements MouseListener{
public void mousePressed(MouseEvent e) {}
public void mouseReleased(MouseEvent e) {}
public void mouseEntered(MouseEvent e) {}
public void mouseExited(MouseEvent e) {}
public void mouseClicked(MouseEvent e) {
int clickCount=e.getClickCount();
if (clickCount==1){
JOptionPane.showMessageDialog(null, "DoubleClick");
}
}
}