• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

images in JList

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Rancher
Posts: 3279
30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Add ImageIcon's to the ListModel, not Image's.

 
Nesrin aboud
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
so how can I select from the ListModel certain icon to get the image and save it to folder or database
 
Sheriff
Posts: 67670
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"nesrin ab", please check your private messages for an important administrative matter.
 
Rob Camick
Rancher
Posts: 3279
30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Read the ImageIcon API.
 
Nesrin aboud
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried another solution but also failed
please if any one can help me




 
Nesrin aboud
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in the last one there is no exception thrown but the images do not appear in the list
 
Rob Camick
Rancher
Posts: 3279
30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I tried another solution but also failed



Why? I already gave you the solution.
 
Nesrin aboud
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
> I made an applet
> images[i] = ImageIO.read(new File(path));

won't work in applets

google
getCodeBase()
 
Nesrin aboud
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why Michael
and where to add the getCodeBase()
 
Rob Camick
Rancher
Posts: 3279
30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you all very much.
 
I'm THIS CLOSE to ruling the world! Right after reading this tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic