• Post Reply Bookmark Topic Watch Topic
  • New Topic

Selecting List Items on right Click  RSS feed

 
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!