Put the logo.png
file in the same package as the class that's calling it
ProjectRoot
src
MyClass.java
logo.png
and use
ImageIcon icon = new ImageIcon(getClass().getResource("logo.png"));
setIconImage(icon.getImage());
See Load Image icon Exception for more details