NiftyGUI 1.3 Popup Contoller?

I’ve looked at the Nifty examples and I can’t seem to figure out if this is possible. I would like to create a pop up that acts as a “buy screen” that overlays on top of the current HUD display. From what I understand about a popups, they stop click events from reaching layers below them which is exactly what I want. Is it possible to assign a java controller class to a pop up like you can do with a screen?

The Nifty Wiki has now an article about popup layers that might help.

And yes you can add a controller=“some.class” to the popup element as well!

I have read that article, but I don’t see anything about adding a controller. I’m sorry, I failed to mention I’m doing this all in java, I tried the following, but it isn’t working:


new PopupBuilder(“popupExit”) {


controller(hud); // doesn’t work, where do I place this line?






you’ve placed that line perfectly fine!

there currently is one catch with using controllers this way. the instance “hud” you’re calling that controller() method with will not actually be used by Nifty. instead of that instance Nifty will look at the class (!) of “hud” and will try to create a new instance using the default constructor (which must be public and must not require any parameters). what might happen in your case is, that this class has no default constructor, the constructor is private, the class is a nested class or there is another something that prevents Nifty to create a new instance of the class.

you will get a warning in the log in that case which will look something like the following message:

[java]1309627447121 WARNING [] class [de.lessvoid.nifty.examples.controls.ControlsDemo$9$1] could not be instanziated (java.lang.InstantiationException: de.lessvoid.nifty.examples.controls.ControlsDemo$9$1)[/java]

that - rather odd - behaviour is a remainer of Niftys XML-only past where you would only be able to set a classname in the XML.