Custom JList, adding JPanels so I can display images
1 posts in topic
Flat View  Flat View

Posted By:   Jason_Jakob
Posted On:   Friday, August 1, 2003 07:40 PM

I would like to create a JList that is populated with multiple thumbnail images. I have been able to do it with imageicons, but I want to make it a little nicer looking.

I was thinking of adding a JPanel for each item, and on the JPanel I have a nice raised border, and an image in the center.

Is this possible to add to a JList?

I realize that I will need custom AbstractListModel and DefaultListCellRenderer classes. Anyone have experience with this?

Re: Custom JList, adding JPanels so I can display images

Posted By:   Bahman_Barzideh  
Posted On:   Saturday, August 2, 2003 01:31 PM

You may or may not need a custom ListModel, but you will certainly
need a customized ListCellRenderer (and more likely than not it would not have anything to do with DefaultListCellRenderer). The ListModel should only keep track of raw data. For example, in your case, it
might keep track of the thumbnail image and the path to the actual
image. How the item is displayed in the JList is the realm of
the ListCellRenderer. To take your analysis one step
further, you would derive a class from JPanel that implements ListCellRenderer. Check Sun's web site. They
might have some examples you can look into.
About | Sitemap | Contact