Original Post
🔒 Locked
loading images in java
Advertisement
You would need to make a separate class like you've suggested. You could have a method such as getImage(imageName). It would be handy to store the images so they don't have to be loaded every time. You could use a hash map for this, using the image's path/name as a key. That way, when you request an image from the class it will look up the hash map and return the image. If the image hasn't been loaded then go ahead and load it.
javax.imageio.ImageIO.read(File file) works like a charm, just be sure to do it before you actually need the image.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement