Jump to content

Images in array


Sigmahokies

Recommended Posts

Hi everyone, I am still learning Java. I am trying to create an array with images. I have images in folder, but I can't figure how to start to have images in array. How can I do that? I checked around in google, none of them make sense, more likely off topic to image icon. I need to tell java to pull all images from folder into array, so i can process programming. can you please show how to do that? Thank you so much.

Gary

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 years later...

Hello , @Sigmahokies

Please try this code ,To Images in array

public class DeckOfCards extends Applet {

    public void init() {

       Image[] clubs = new Image[13];
       for (int i = 0; i < clubs.length; i++ ) {
            clubs[i] = getImage( getDocumentBase(), "c" + (i + 1) + ".gif");
        }
        ...
    }
}
I hope this code will be usefull for you.

Thank you.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...