*
The moose likes Swing / AWT / SWT and the fly likes How to display Right-click popup menu in JPanel? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to display Right-click popup menu in JPanel?" Watch "How to display Right-click popup menu in JPanel?" New topic
Author

How to display Right-click popup menu in JPanel?

ujjal dey
Greenhorn

Joined: Jun 12, 2009
Posts: 2
Hi All,

In my application, a JPanel gets displayed in a JWindow. I need to add a right-click menu (with 'Exit' and 'About') in that JPanel.

I am not able to add the popup menu in the JPanel.

Can anybody please help me out??? Any pointer would be helpful.

Thanks in advance...
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
some info in a similar post here

http://forums.sun.com/thread.jspa?threadID=5393146&tstart=0
Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
This page does a good job of explaining mouse Events, and deals specifically with how to tell if a mouse click event is a right click, once you determine that you can take the appropriate steps to display your menu.

http://www.faqs.org/docs/javap/c6/s4.html

edit: You'll be probably using a JPopupMenu, and probably the show() method of this class to actually display the menu
Ramses Butarbutar
Ranch Hand

Joined: Jun 16, 2009
Posts: 52
ujjal dey wrote:Hi All,

In my application, a JPanel gets displayed in a JWindow. I need to add a right-click menu (with 'Exit' and 'About') in that JPanel.

I am not able to add the popup menu in the JPanel.

Can anybody please help me out??? Any pointer would be helpful.

Thanks in advance...


This is a sample test using JPopup.. you can add the pannel.. and change item listener for your purpose.. But first , follow the link that suggested by others to determine and understand your purpose.



At the center of non-violence stands the principle of love
.... Martin Luther King, Jr.
 
wood burning stoves
 
subject: How to display Right-click popup menu in JPanel?
 
Similar Threads
disable popup menu of JOptionPane
JFileChooser
junit - find menu component for popupmenu
JPopupMenu or JMenu - neither is quite what I'm after.
Right Click Menu on a JList