This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Right-click menu  RSS feed

 
Olivier Legat
Ranch Hand
Posts: 176
Chrome Mac Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,

I want to implement a right-click menu; lets say when you click on JLabel you get click a drop down menu that appears right beside the mouse cursor.

How would I do this? All I found was this (javax.swing.JList) and this javax.swing.ListCellRenderer. The JList doesn't seem to be what I'm looking for because it's a JComponent. Will I have to implement this myself or is there a fancy Java class I can use

I also found this. It seems it's possible to achieve this using a JMenu. Is this true?

Thank-you
 
Rob Camick
Ranch Hand
Posts: 2787
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See: Bringing Up a Popup Menu.
 
Olivier Legat
Ranch Hand
Posts: 176
Chrome Mac Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Brilliant! Many thanks Rob
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!