• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

How to display Right-click popup menu in JPanel?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
some info in a similar post here

http://forums.sun.com/thread.jspa?threadID=5393146&tstart=0
 
Ranch Hand
Posts: 686
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.

 
Did you miss me? Did you miss this tiny ad?
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic