This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
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

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTable and popup" Watch "JTable and popup" New topic

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.
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) can get the Point from event.This goes like this..
public void mouseClicked(MouseEvent e){
int row= table.getRowAt(e.getPoint());

Sun Certified Java Programmer
I agree. Here's the link:
subject: JTable and popup
It's not a secret anymore!