adg
asked on
Context menu on JTable
Hi, I want to have a context menu so when the user right-clicks on my jtable I can offer a menu of choices. When a choice is selected it will operate on the row that was clicked on so I need to pick up both the menu choice and the row that was right-clicked on. Can you tell me how to do this?
Thanks!
Add a mouseListener to your jTable and react on mouseClicked()
Add a MouseListener to your table and have it get the row clicked on according to the click coords, and then popup a JPopupMenu.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the quick response!
>> just makes sure that right-clicking an item also selects that item. Maybe that's not needed in your app.
I do need that! I'll give it a try and get back to you - probably in around 10 hours.
>> just makes sure that right-clicking an item also selects that item. Maybe that's not needed in your app.
I do need that! I'll give it a try and get back to you - probably in around 10 hours.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Of course, JPopupMenu! I should have known. I gotta read more about Swing. :*)
Thanks both for the exellent examples. I'm splitting the points, appreciate the help!
Thanks for accepting
(: