Reputation: 7
I have an imageicon array whats an easier way of declaring them than just declaring each individual image. ImageArray[0] = new ImageIcon("resources/images/cards/6.png");
Upvotes: 0
Views: 4249
Reputation: 6412
Two most common ways:
ArrayList
, then (if needed) call toArray()
Upvotes: 0
Reputation: 7779
Assuming the images are 0.png through 51.png in the resources.images/cards folder:
ImageIcon[] images = new ImageIcon[52]
for(int i=0;i<52;i++){
images[i] = new ImageIcon("resources/images/cards/"+i+".png");
}
Upvotes: 5