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

JList

 
emma dawdry
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a JList populated with data. When the user has double clicked on one of the items in the list, I need to maniupulate that item. I have implemented the MouseListener which returns an index of the row the user has clicked on. How do I then get the actual data from that row back?
I have used a corresponding linkedlist to store the data displayed in the JList, so that I can search through that using the index returned by the mouse click but this seems a bit long-winded
Thanks
Emma
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From JList: getSelectedValue() should be simplest. Alternately getModel().getElementAt(index) will do it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic