The project runs fine when I click play in Eclipse but after I created the runnable JAR file, The ImageIcon
for the button is gone.
The images are stored within the src folder, uder a subfolder images.
I created the image icon as
I ended up creating a very unstructured monolithic code for screen recorder and now it is slightly difficult to implement what he said.
I was wondering if there is a way like creating a class or interface that will contain all these resources.
public class embeddedResources {
public static Icon blackCursor;
public static Icon whiteCursor;
...
...
}
Then all I have to do is import these statics and in my main ScreenRecorder
class,
this.blackCursor = embeddedResources.blackCorsor;
I am using this method to read image into BufferedImage
where IconManager is class where it is defined.
private static BufferedImage readBufferedImage (String imagePath) {
try {
InputStream is = IconManager.class.getClassLoader().getResourceAsStream(imagePath);
BufferedImage bimage = ImageIO.read(is);
is.close();
return bimage;
} catch (Exception e) {
return null;
}
}