I want to use the setImage(NiftyImage image) method of an ImageRenderer to change its image. How can I build the required NiftyImage object from a given path though?

That’s what I use with my game.


public void setListPreviewImage() {

if (!isListImgSet) {

NiftyImage listPreviewImage = nifty.getRenderEngine().createImage(“listPreviewImg.png”, false); //NOI18N

nifty.getCurrentScreen().findElementByName(“listPreviewImage”).getRenderer(ImageRenderer.class).setImage(listPreviewImage); //NOI18N

isListImgSet = true;




“listPreviewImg.png” is an image I get from the offscreen rendering class I’m using. That image is sent to the cache directly.

Hopefully that should help you out.


Thank you, it works.