I have added an image for my button,but when I run that frame this exception will be thrown .why?please help me.
init:
deps-jar:
compile-single:
run-single:
This means, that getClass().getResource("/Images/yahoo_1.gif")
returns null
.
JavaDoc states that this happens if
the resource could not be found or the invoker doesn't have adequate privileges to get the resource.
Check if getResource
really returns null
:
System.out.println(getClass().getResource("/Images/yahoo_1.gif"));
Make sure that your path is correct and that it is in your classpath.
EDIT:
I just tried it with NetBeans. I created the following structure
Source Packages
Images
yahoo_1.gif
and your code worked fine. Is this your structure?
Try to right-click on your application and select Clean and Build
.