Reputation: 227
When using the new GUI Builder (CN1 plugin v3.6.0) I can attach an image from my res file to a Button and it appears in the preview nicely
but when I try to run the code in the Simulator I get a NullPointerException on the line
gui_ordersButton.setIcon(resourceObjectInstance.getImage("Orders.png"));
As this is in the magic "do not edit below this line" block how can I fix this?
Many thanks.
Upvotes: 1
Views: 51
Reputation: 52760
Two elements can throw a null pointer from this exact line:
gui_ordersButton.setIcon(resourceObjectInstance.getImage("Orders.png"));
gui_ordersButton
or resourceObjectInstance
. If the image isn't available in the resources the null pointer will come from the setIcon
method.
I'm guessing resourceObjectInstance
is null because you changed something about the way resources are loaded in the default project or you used the constructor of the form that passes null as the resources object.
Upvotes: 1