Nifty.createPopup hath defeated me

Everything is null. What do you get when you call the create popup function? Null. All the time. I have yet to call that function and not get a nullpointerexception.

Here is the xml and relevant java code:

[java] public void initializePopups(){
//<editor-fold desc=“Win By Destruction” defaultstate=“collapsed”>
winByDestruction = nifty.createPopup(“popup”);
Menu wbdMenu = winByDestruction.findNiftyControl("#menu", Menu.class);
wbdMenu.setWidth(new SizeValue(“100px”)); // must be set
wbdMenu.addMenuItem(“The world has suffered over 5,000,000$ in losses over your malware.”, “You have won.”);
<?xml version=“1.0” encoding=“UTF-8”?>
[java]<nifty xmlns=“” xmlns:xsi=“” xsi:schemaLocation=“”>
<!-- +++++++++++++++++++++++++++++++++++++++ -->
<!-- Malware Hub -->
<!-- +++++++++++++++++++++++++++++++++++++++ -->
<screen id=“start” controller=“Game.Screens.MalwareHub”>
<layer id=“Background” childLayout=“center”>
<panel id=“BackgroundPanel” height=“100%” width=“100%” childLayout=“center”>
<image id=“BackgroundImage” filename=“Textures/Backgrounds/PregameBackground.png”></image>

    &lt;layer id="UI" childLayout="center"&gt;

        &lt;panel id="TopLeftUI" valign="top" align="left" width="12%" height="100%" childLayout="center"&gt;                
            &lt;image id="Government_Stats" filename="Interface/MalwareHub/UI/Government_Stats.png"&gt;&lt;/image&gt;

        &lt;panel id="BottomMiddleUI" valign="bottom" align="right" childLayout="horizontal" height="20%" width="88%"&gt;
            &lt;image id="InfectedStats" filename="Interface/MalwareHub/UI/Infected_Stats.png"&gt;&lt;/image&gt;
            &lt;image id="MoneyStats" filename="Interface/MalwareHub/UI/Money_Stats.png"&gt;&lt;/image&gt;
            &lt;image id="DamageStats" filename="Interface/MalwareHub/UI/Damage_Stats.png"&gt;&lt;/image&gt;

        &lt;panel id="TopRightUI" valign="top" align="right" childLayout="center" height="40%" width="30%"&gt;                  
            &lt;image id="Malware Button" filename="MalwareHub/Buttons/Malware_Btn.png"&gt;&lt;/image&gt;
            &lt;interact onClick="loadUpgrades()"&gt;&lt;/interact&gt;

    &lt;layer id="Text" childLayout="horizontal"&gt;
        &lt;panel id="GovernmentInvestigationPanel" width="12%" align="center" childLayout="center" valign="center"&gt;
            &lt;text id="GovernmentInvestigationText" text="0%" font="Interface/Fonts/DifficultyMenu/STechMono14px.fnt"&gt;&lt;/text&gt;

        &lt;panel id="BigThreeStatsText" width="88%" align="center" childLayout="horizontal" valign="bottom" height="25%"&gt;
            &lt;text id="InfectedText" text="0 Infected" font="Fonts/DifficultyMenu/STechMono14px.fnt" width="40%" valign="center"&gt;&lt;/text&gt;
            &lt;text id="MoneyText" text="0 $" font="Fonts/DifficultyMenu/STechMono14px.fnt" width="22.5%" valign="center"&gt;&lt;/text&gt;
            &lt;text id="DestructionText" text="0 $" font="Fonts/DifficultyMenu/STechMono14px.fnt" width="40%" valign="center"&gt;&lt;/text&gt;
    &lt;popup id="popup" childLayout="center" backgroundColor="#000a"&gt;
         &lt;control id="#menu" name="menu" /&gt;
         &lt;panel style="nifty-panel-red" childLayout="center" padding="18px,28px,40px,16px" width="30%" height="20%" align="center" valign="center"&gt;


I have absolutely no useful input to this thread… I just wanted to say the the topic title made me laugh; :wink: Very stoic!

2/2 Threads that shall be left unsolved for all eternity…

Somebody needs to learn to be a little patient. It hasn’t even been a day :). That being said… createpopup fails because you haven’t defined a popup correctly. You need to define them at the same level as the screen nodes. Popups are meant to be reusable components that could be called from any screen. I would also name it something other than “popup” since there could be a naming conflict there.

That solved the first issue, but Menu is now null. Any hints?

I believe that when you put “#” in front of an ID it actually ends up being {parent id}#menu and not #menu but I could be wrong. Either way, you are trying to retrieve an ID of an element that it can’t find which is why it is null.