I am designing a Java program to set icon to JLabel
when clicking the corresponding button. I want to know ways to check whether the img exists before calling:
ImageIcon myIcon = new ImageIcon(getClass().getClassLoader().getResource(path));
I'm not allowed to use try catch!
If the image does not exist in the supplied path, the URL returned from getResource(..)
will be null
.