File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JList

 
Rajeev Iyer
Ranch Hand
Posts: 42
  • 0
  • 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
  • 0
  • 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:
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic