This is the code I use to load Images. The class has a constant ICON_PREFIX which is the location of all my images.
private static final
String ICON_PREFIX = "/suncertify/framework/gui/icons/";
public static Icon getIcon(String iconName) {
Icons icons = new Icons();
InputStream in = icons.getClass().getResourceAsStream(ICON_PREFIX + iconName);
if (in == null) {
System.out.println("No icon found for name " + iconName);
return null;
}
Icon icon = null;
try {
byte[] bytes = new byte[in.available()];
in.read(bytes);
icon = new ImageIcon(bytes);
} catch (IOException e) {
System.out.println("Error reading image");
e.printStackTrace();
}
return icon;
Hope that helps