Author
images in JList
Nesrin aboud
Greenhorn
Joined: Feb 08, 2010
Messages: 16
posted Feb 09, 2010 07:20:56
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
Messages: 655
posted Feb 09, 2010 08:45:50
Add ImageIcon 's to the ListModel , not Image's.
Nesrin aboud
Greenhorn
Joined: Feb 08, 2010
Messages: 16
posted Feb 09, 2010 10:30:57
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 opinionated walrus
Sheriff
Joined: Jan 10, 2002
Messages: 36357
posted Feb 09, 2010 10:32:47
"nesrin ab", please check your private messages for an important administrative matter.
[Smart Questions ] [JSP FAQ ] [Books by Bear ] [Bear's FrontMan ] [About Bear ]
Rob Camick
Ranch Hand
Joined: Jun 13, 2009
Messages: 655
posted Feb 09, 2010 11:46:59
Read the ImageIcon API.
Nesrin aboud
Greenhorn
Joined: Feb 08, 2010
Messages: 16
posted Feb 09, 2010 19:59:11
I tried another solution but also failed
please if any one can help me
Nesrin aboud
Greenhorn
Joined: Feb 08, 2010
Messages: 16
posted Feb 09, 2010 20:00:08
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
Messages: 655
posted Feb 09, 2010 21:04:31
I tried another solution but also failed
Why? I already gave you the solution.
Nesrin aboud
Greenhorn
Joined: Feb 08, 2010
Messages: 16
posted Feb 09, 2010 21:56:21
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
Rancher
Joined: Jun 09, 2003
Messages: 3073
posted Feb 09, 2010 22:08:16
> I made an applet
> images[i] = ImageIO.read(new File(path));
won't work in applets
google
getCodeBase()
Nesrin aboud
Greenhorn
Joined: Feb 08, 2010
Messages: 16
posted Feb 09, 2010 22:13:40
why Michael
and where to add the getCodeBase()
Rob Camick
Ranch Hand
Joined: Jun 13, 2009
Messages: 655
posted Feb 09, 2010 22:23:22
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
Greenhorn
Joined: Feb 08, 2010
Messages: 16
posted Feb 12, 2010 06:26:35
Thank you all very much.