This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes JList Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JList" Watch "JList" New topic


Rajeev Iyer
Ranch Hand

Joined: Jun 19, 2002
Posts: 42
How can I add Images(ImageIcons) to a JList??
Nathan Pruett

Joined: Oct 18, 2000
Posts: 4121

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:

Write once, run anywhere, because there's nowhere to hide! - /. A.C.
I agree. Here's the link:
subject: JList
Similar Threads
JList + Vector
Makenon border swing Components
How to set the size of aJList?