File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Right click in JList item Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Right click in JList item" Watch "Right click in JList item" New topic

Right click in JList item

Nathan Paris

Joined: Jun 21, 2000
Posts: 28
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.
San Su
Ranch Hand

Joined: Jul 06, 2001
Posts: 313

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:
subject: Right click in JList item
It's not a secret anymore!