Calling Nifty from Java

Hello.

How can I call my nifty panel to show from my java code? I mean - i’m checking conditions in java, and if its true, i tell nifty - “ok, show the panel”, if its false - “dont show/hide”

When you have a Nifty instance and assuming that your panel stays in the current screen , you can do like this
[java]
boolean yourtest = somecondition;
Element panel = nifty.getCurrentScreen().findElementByName(“yourelementID”);
panel.setVisible(yourtest);
[/java]

This often is done in Bind method of your ScreenController , but if you have a valid nifty instance you can do it every where. :slight_smile:

1 Like

Its explained in our wiki too…

Thank you!