• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Right click in JList item

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a JList and need to know how to right click on a specific Item in the list. I.e. the list will have some items and a right click would bring up a Menu for that item.
Thanks,
Nathan
 
Ranch Hand
Posts: 313
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Right click will not select an item in JList. To poptup menu
on right click, you need to add mouseListener to JList
and listen for mousePressed event.
public void mousePressed( MouseEvent e ){
if (SwingUtilities.isRightMouseButton(e)){
// Right mouse button is pressed.
// Add popup menu code here..
}
}
Sankar S.
reply
    Bookmark Topic Watch Topic
  • New Topic