Forums Register Login

Popup Menu

+Pie Number of slices to send: Send
Hi all

I have a JTable, and if a user "right clicks" on a row, a pop up menu should come up.

This is so far what I have done, but its not working correctly.




The pop up menu does come up when I "right click", however the screen of the table disappears and the
popup menu comes up on the corner of the screen, i want it to be where the user "right clicks"

Your help will be greatly appreciated

Pranay
+Pie Number of slices to send: Send
 

Pranay Narotam wrote:


Please use MouseEvent.BUTTON3; it will make reading a bit easier, and if Sun decides to change its value from 3 to something else like -3, your code will still work.


You're using a BorderLayout, which allows only one component at its center. By using add(jpMenu) you are replacing the table with the popup menu.

This also isn't the way popup menus work. They should not get added to an existing control; instead, they have their own window which you can show as follows:
Combined with your mouse listener:
+Pie Number of slices to send: Send
Hi

Thanks alot, It works perfectly



Pranay
+Pie Number of slices to send: Send
Hi again

I am looking at the code, it works perfectly but i don't seem to understand why there is a parameter "COMPONENT" in the method


Thanks again

Pranay
+Pie Number of slices to send: Send
You need to show the popup for a specific component. I've decided to get that from the mouse event, but you can hard code it to be your table as well of course. In that case, you can remove the entire parameter:
My honeysuckle is blooming this year! Now to fertilize this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1578 times.
Similar Threads
JMenu problem
Right click in text editor
System Tray - double click icon to set visible
How to add a shortkey to Menu
JPopup and JTree Problem
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 05:46:10.