File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Right click in JList item

 
Nathan Paris
Greenhorn
Posts: 28
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
San Su
Ranch Hand
Posts: 313
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic