aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes How to add icons along with the text in a JList[urgent] Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to add icons along with the text in a JList[urgent]" Watch "How to add icons along with the text in a JList[urgent]" New topic
Author

How to add icons along with the text in a JList[urgent]

netharam ram
Ranch Hand

Joined: Aug 09, 2001
Posts: 202
Hi, I have Jlist that lists the files & folders in as pecified path.I want to differentiate folders from files,so I wish to add a folder icon along with the folder path in the Jlist.Is this Possible?Please reply me as soon as possible.
Happy middling with java.
Netharam :roll:
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

All you have to do is extend DefaultListCell Renderer to do what you want (if the current item is a directory, add an icon showing it is a Directory instead of a file), then call setCellRenderer() on your JList with an instance of your new ListCellRenderer.

-Nate


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
netharam ram
Ranch Hand

Joined: Aug 09, 2001
Posts: 202
HI, Nathan could u please reply with a code snippet for I've very less knowledge in swing.
Happy middling with java. :
Netharam. :roll:
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Here's some code that should help you out with your renderer problem...



-Nate
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to add icons along with the text in a JList[urgent]