This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes JTable - selection of a right-click 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 - selection of a right-click" Watch "JTable - selection of a right-click" New topic

JTable - selection of a right-click

Amit Rosner

Joined: Dec 03, 2001
Posts: 22
I want to be able to select a JTable row on a mouse right-click, just as it happens on a mouse left-click, for opening a popup menu. Opening the menu itself is no problem. The problem is that the row is not selected.
How can I do that?
lavanya subramanian
Ranch Hand

Joined: Nov 03, 2000
Posts: 52
Hi Amit,
try this code and i think this might help you,
table1.addMouseListener(new MouseAdapter()
public void mouseClicked(MouseEvent me)
if(SwingUtilities.isRightMouseButton(me) == true)
int row = table1.rowAtPoint(me.getPoint());

//your popup menu goes here.
try and let me know,
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: JTable - selection of a right-click
It's not a secret anymore!