Nifty - creating drawable canvas as part of the GUI

Hello JMonkeys,
We’d like to change a Swing GUI of one of our projects to a Nifty GUI.
I’ve checked the documentation and almost everything seems ok for the change.
The only problem is that we have a drawable canvas (so using mouse events and updating the drawn bufferedImage), but we haven’t found anything about making a custom drawable nifty component.

I think the mouse events can be processed correctly, but I don’t know if we can draw an image on a Nifty component to show this canvas.

Has anyone tried that yet or do you have any tip?
Thanks as always,

Pardon me in case I don’t understand your question correctly.
Can’t you just display the image into which you are painting using nifty ? (ex: using the image control)

That’s what I’m asking, as I haven’t seen any information about it :smile:

Basically I don’t know if I can:

  1. Show a white image (bufferedImage) in a Nifty Panel
  2. Click on it and get the pixel coords relative to the image
  3. Change the bufferedImage
  4. Update the rendered canvas in the Nifty Panel

I know it’s possible but I can’t tell you how as I wouldn’t use nifty for that :smile:

Maybe with that ?
Then you might be able to do something with your image element.

Someone else should be able to provide you a more precise answer :smile:

I found this discussion:

And he says “Current Nifty, 1.3.x or 1.4.x don’t support custom drawing to a screen.”

If this is always true, then we wouldn’t be able to work on this canvas and this is why I asked.

Let’s wait for anyone who can answer to this :smile:

I’m having sort-of-same problem here:

Theoretical you can create a texture2D and exchange this new image for an old in nifty (see code in my question).
Sadly my solution only works in simpleInitApp() so far.

Let’s keep fingers pressed, some nifty-folks have a more generally working answer.