Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JTable and mouseclicks...

843805Sep 26 2005 — edited Feb 6 2006
I 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");
}
}
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 6 2006
Added on Sep 26 2005
19 comments
1,403 views