Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Right Click List Selection

 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
lavanya subramanian
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic