Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JList

 
Rajeev Iyer
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi...
How can I add Images(ImageIcons) to a JList??
Thanks....
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You would make a new ListCellRenderer that displays Icons and call setCellRenderer() on the JList, passing in your new ListCellRenderer class.

The easiest way to do this would be to extend DefaultListCellRenderer and override the getListCellRendererComponent method to something like this:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic