Dato che sto utilizzando questa classe:
per il caricamento di tutte le immagini, posso inserire questo tuo metodo:codice:import java.awt.Image; import java.awt.image.BufferedImage; import java.io.IOException; import javax.imageio.ImageIO; import javax.swing.ImageIcon; public class ImageLoader { public static BufferedImage loadBufferedImage(String path) throws IOException{ return ImageIO.read( ImageLoader.class.getResource(path) ); } public static Image loadImage(String path) throws IOException{ return loadIcon(path).getImage(); } public static ImageIcon loadIcon(String path) throws IOException{ return new ImageIcon( ImageLoader.class.getResource(path) ); } }
nella classe che ho scritto sopra e richiamare da lì il metodo che mi hai detto ?codice:public static URL getIconURL(String name) { return AppResources.class.getResource(name); }