aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JList and images Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JList and images" Watch "JList and images" New topic
Author

JList and images

Titus Abraham
Ranch Hand

Joined: Jun 03, 2009
Posts: 36
Hello ,

I need to display as a list <contact_image> contact name "status message" <status icon>
Basically image, text and a image. I understand that we can tweak the JList to have a image and a text by putting the icon of teh label as the image but can mine be done ..
I checked through java tutorials but they didn't seem to come to this point..

Awaiting a speedy reply.


best regards,
Titus

my email id is: titus.mortal@gmail.com
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19783
    
  20

You should create your own ListCellRenderer, and apply that. Extending DefaultListCellRenderer is the easiest:


Titus Abraham wrote:Awaiting a speedy reply.

Please Ease Up

my email id is: titus.mortal@gmail.com

Please Use The Forum, Not Email


Moving to Swing.

SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Titus Abraham
Ranch Hand

Joined: Jun 03, 2009
Posts: 36
Hey,

Thanks for the reply.
according to the method told by you
here we can set the text and the icon of the Label. but i would lik 2 images to be dispalyed in 1 row of the list
if i use this cellrender method i would get <Image>text but i wanted <Image>text<Image>

Any answers?

regards,
Titus
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19783
    
  20

You can create your custom renderer that returns a JPanel with three labels. A quick and untested attempt:
I still extend DefaultListCellRenderer because basically the label will be the most complex.
Titus Abraham
Ranch Hand

Joined: Jun 03, 2009
Posts: 36
Thanks a ton its working fine..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JList and images