This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Right click in JList item" Watch "Right click in JList item" New topic
Author

Right click in JList item

Nathan Paris
Greenhorn

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.
Thanks,
Nathan
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.
 
Consider Paul's rocket mass heater.
 
subject: Right click in JList item
 
Similar Threads
ConcurrentModificationException
Right Click List Selection
problem selecting JList item
JList
JList Select on MouseEntered