Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

getClickCount always returns 1 for JTable  RSS feed

 
Gary Frick
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone tell me why the getClickCount is always returning a value of 1 even for double-clicks?
Thanks,
Gary
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps you could post some code? Here is an example where I know it works.
 
Gary Frick
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul,
My code is essentially identical. So I'm not sure what other setting(s) may be affecting this outcome. In debug, if I breakpoint on the 'If' statement, e.getClickCount() always == 1.
Gary
table.addMouseListener(new MouseAdapter()
{
public void mouseClicked(MouseEvent e)
{
if (e.getClickCount() == 2)
{
Point p = e.getPoint();
int row = table.rowAtPoint(p);
int column = table.columnAtPoint(p); // This is the view column!
 
Gary Frick
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul,
After taking out some debug stuff, it is now working. I don't have a good explanation, since I put in the debug code specifically to catch the problem. Anyway it's working.
Sorry for the bother
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Compile enough and test enough the problem goes away
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!