wood burning stoves*
The moose likes Swing / AWT / SWT and the fly likes JTable and popup Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTable and popup" Watch "JTable and popup" New topic
Author

JTable and popup

Sri Rangan
Ranch Hand

Joined: Dec 08, 2001
Posts: 160
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

Joined: Dec 08, 2001
Posts: 160
I figured it out.
row num = table.rowPointAt(new Point(e.getX(),e.getY()));
Bhagya Tangutur
Ranch Hand

Joined: Oct 21, 2002
Posts: 88
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());
}
}


Sun Certified Java Programmer
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTable and popup