• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTable and popup

 
Sri Rangan
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have to show a popup menu with the row details when user does not select a row in JTable and right click the mouse.
I can detect the right mouse click ny the following code...

But how do I find out the row number on the table.
Thanks
Sri
 
Sri Rangan
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I figured it out.
row num = table.rowPointAt(new Point(e.getX(),e.getY()));
 
Bhagya Tangutur
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can get the row from Table by calling getRowAt(Point) method.you can get the Point from event.This goes like this..
public void mouseClicked(MouseEvent e){
if(SwingUtilities.isRightMouseButton(e)){
int row= table.getRowAt(e.getPoint());
}
}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic