This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Popup menu not showing when JTable cell clicked Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Popup menu not showing when JTable cell clicked" Watch "Popup menu not showing when JTable cell clicked" New topic
Author

Popup menu not showing when JTable cell clicked

Jennifer Sohl
Ranch Hand

Joined: Feb 28, 2001
Posts: 455
I have a JTable that I want to popup a menu by right clicking on a certain cell. I have created a PopupMenu class that takes a component argument, and that component gets the mouse listener in the PopupMenu class added to it. I also made a method to set the component in the PopupMenu class.
I create an instance of the PopupMenu class passing it a null for component.
Then after I've populated my table with data, I set the component in the PopupMenu class by calling the getTableCellRendererComponent() method in the selectTableRow() method (See below). However, the popup menu never comes up. Could someone tell me what I'm doing wrong?
Here's some code I'm using:


Thanks for any help!
James Redpath
Greenhorn

Joined: Aug 02, 2003
Posts: 13
Have you tried setting the setLightWeightPopupEnabled(false)
for the JPopupMenu instance after creating the popup menu?
The default is true and may be behind your table.
popup.setLightWeightPopupEnabled(false);
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Popup menu not showing when JTable cell clicked
 
It's not a secret anymore!