(First of all, I'm sorry If there is like a million questions like this. I've tried everything I can and this is driving me nuts!)
I'm trying to had an icon to a JButton but I keep getting an IllegalArgumentException
caused by ImageIO.
Here's what I have:
//Other UI elements ^
JButton X = new JButton("Clear");
//com.oliveira.ux is the package name
Image img = ImageIO.read(getClass().getResource("/com.oliveira.ux/resource/gtk-clear.png"));
Icon clear = new ImageIcon(img);
//More UI elements
The Icon is located under src/PACKAGE NAME/resource/. (I use eclipse). I've tried to change the location on the code above (the one I wrote here was the last one I tried) but all I get is an IllegalArgumentException when I run de .jar. Any suggestions?
Many thanks in advance
Here's the full error message:
Caused by: java.lang.IllegalArgumentException: input == null!
at javax.imageio.ImageIO.read(Unknown Source)
at com.oliveira.ux.Main.<init>(Main.java:146)
at com.oliveira.ux.Main.main(Main.java:75)
... 5 more
This points to the ImageIO part in the code I wrote above.