Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Selecting List Items on right Click

 
Khurram Zaman
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
I want to select list items on right click on JList. Can anyone tell me about this?
Regards,
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
attach a MouseListener to the JList and get the Point of the mouse click. you can than set the selection in the JList automatically.
see JList.locationToIndex(Point), JList.setSelectedIndex(int), and JList.setSelectedValue(Object, boolean) (for scrolling), JViewport.scrollRectToVisible(Rectangle).
Chantal
 
Did Steve tell you that? Fuh - Steve. Just look at this tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!