*
The moose likes Beginning Java and the fly likes how to load a directory of images to an applet? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how to load a directory of images to an applet?" Watch "how to load a directory of images to an applet?" New topic
Author

how to load a directory of images to an applet?

Khair Bahir
Greenhorn

Joined: Aug 01, 2011
Posts: 14
Hey guys,

This is a snippet of how I'd normally load images (where the images are cards) from the directory "images":



What if I had 52 cards? Is there a better way than to write out every statement?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37884
    
  22
If they have names with consecutive numbers, you can run a loop and add the numbers to the strings.

getImage(getDocumentBase(), "image" + i + ".gif");

That depends on the images being named consecutively.
 
Consider Paul's rocket mass heater.
 
subject: how to load a directory of images to an applet?
 
Similar Threads
card game
random images
Images in Java
Image formats allowed
Using arrays to randomly generate images? (applet)