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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "images in JList" Watch "images in JList" New topic
Author

images in JList

Nesrin aboud
Ranch Hand

Joined: Feb 08, 2010
Posts: 48

Hi there,

I made an applet and added a JList object into it and I have a folder containing images (0.jpg, 1.jpg, 2.jpg)

I want to add these images in the JList object in the form of loop when I tries this



the list resulted in list of object reference not image itself
so is there any solution for this issue

and thank you very much
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2090
    
    7
Add ImageIcon's to the ListModel, not Image's.

Nesrin aboud
Ranch Hand

Joined: Feb 08, 2010
Posts: 48
so how can I select from the ListModel certain icon to get the image and save it to folder or database
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

"nesrin ab", please check your private messages for an important administrative matter.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2090
    
    7
Read the ImageIcon API.
Nesrin aboud
Ranch Hand

Joined: Feb 08, 2010
Posts: 48
I tried another solution but also failed
please if any one can help me




Nesrin aboud
Ranch Hand

Joined: Feb 08, 2010
Posts: 48
in the last one there is no exception thrown but the images do not appear in the list
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2090
    
    7
I tried another solution but also failed


Why? I already gave you the solution.
Nesrin aboud
Ranch Hand

Joined: Feb 08, 2010
Posts: 48
can you give a sample code,
I tried your solution, but I have no experience with applets and failed to do it
so if you can write the sequence that is should follow to use the ListModel and ImagIcon
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> I made an applet
> images[i] = ImageIO.read(new File(path));

won't work in applets

google
getCodeBase()
Nesrin aboud
Ranch Hand

Joined: Feb 08, 2010
Posts: 48
why Michael
and where to add the getCodeBase()
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2090
    
    7
but I have no experience with applets


Well, thats an important piece of information to leave out (that this is for an applet).

Read the section from the Swing tutorial on How to Make Applets for an example of using images in an applet.
Nesrin aboud
Ranch Hand

Joined: Feb 08, 2010
Posts: 48
Thank you all very much.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: images in JList
 
Similar Threads
Image Overlapping not proper
Tricky NullPointerException Problem
Displaying image in applet on click event
append multiple jpg images to form multipage jpg Image
Problem with the JScrollPane