aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Right Click List Selection 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 List Selection" Watch "Right Click List Selection" New topic
Author

Right Click List Selection

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Does anyone know how to have the Right Click of a Mouse perform the same function as the Left Click of the mouse when clicking inside a JList.
I have a PopupMenu show when I right click on the list, but I have to left click on the item I want to grab before I can right click. I need the item selected on a right click as well as a left click.
Thanks


GenRocket - Experts at Building Test Data
lavanya subramanian
Ranch Hand

Joined: Nov 03, 2000
Posts: 52
hi gregg,

try javax.swing.SwingUtilities class
JList.addMouseListener(new MouseAdapter()
{
public void mouseClicked(MouseEvent me)
{
if(SwingUtilities.isRightMouseButton(me)== true)
{
}
}
});
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Yeah, that detects the right mouse click. But it does not select the item in the JList. Only a left click will. I need to find out how to have the right click select the item the same as a left click.
But thanks anyway.
 
jQuery in Action, 2nd edition
 
subject: Right Click List Selection