Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

managing my Images in Java

I am building a Java Swing gui and I am wondering what the best way of managing all my images would be. So far I have just been creating images from different classes whenever they are needed, by pointing out the path of each one, for example:

ImageIcon temp= new ImageIcon("resources/pictures/temp.png");

There are 2 things I don't like. First thing would be having all those paths. Second would be that I would prefer a more like "central repository" approach. Does anyone have a better practice to suggest, I was thinking maybe something like an ImageManager that loads all the images at the very start of a program. Can property files help somehow (never used them) with all those paths?

Thanks

like image 982
sakis kaliakoudas Avatar asked Aug 24 '12 18:08

sakis kaliakoudas


1 Answers

Properties can be used for defining some key=value where key would be a unique key and value would be a path to the image. Then, as you suggested, you could use an ImageManager that could define methods that would get a key as a parameter and would return a reference to an ImageIcon or whatever the image type must be.

like image 169
Dan D. Avatar answered Oct 29 '22 16:10

Dan D.