Changing nifty image

I am trying to change a nifty image.
When I follow the tutorial, it doesn’t work.

Java Modifies Nifty Elements and Events

You can also alter the appearance and functions of your nifty elements from Java. Make certain that the element that you want to alter has its id=“name” attribute set, so you can identy and address it.

Here’s an example of how to change an image called playerhealth:

// load or create new image
NiftyImage img = nifty.getRenderEngine().createImage(“Interface/Images/face2.png”, false);
// find old image
Element niftyElement = nifty.getCurrentScreen().findElementByName(“playerhealth”);
// swap old with new image

More info? I mean, using that method should work so there’s probably some other thing … the output and the xml should also help!

I have a piece of string in my hand. How long is it?

Here is my xml:

[java]<panel id=“content-panel” height=“100.0%” style=“nifty-panel-simple” width=“35.0%” childLayout=“vertical”>
<control name=“label” id=“item-name-label” text=“Item name” height=“10%” font=“aurulent-sans-16.fnt” width=“100%” wrap=“true” />
<image id=“inventory-image” height=“30%” width=“100%” filename=“Textures/defaultItem.png”/>
<panel id=“inventory-desc” height=“50%” width=“100%” childLayout=“vertical”>
<control name=“label” id=“desc-label” text=“Item description here” height=“100.0%” font=“aurulent-sans-16.fnt” width=“100%” wrap=“true” />
<control name=“button” id=“inventory-place-buton” style=“green-button” label=“Use this item” childLayout=“center”>
<interact onClick=“placeItemFromInventory()” />

And I use this line:
NiftyImage img = nifty.getRenderEngine().createImage(“Interface/Images/face2.png”, false);
The SDK says there is no method with that parameters, there is a method with name createImage but the parameters should be: createImage(Screen screen, String name, boolean filterLinear)
Error: Method createImage in interface NiftyRenderEngine can not be applied to given types

The nifty variable is just a Nifty object.

The image in the xml file I want to change has id inventory-image

When I use createImage(Screen, String, boolean) my SDK doesn’t give any errors. But when the image becomes changed at runtime, it throws exceptions and there is no visible result.

Problem solved! nifty was changing screen (or something) between creating the image and setting the new image to the ImageRenderer. It was just an error in the sequence.