Can't acces current screen (nifty)

Hi, I have a simple UI:

[java]<?xml version=“1.0” encoding=“UTF-8”?>
<nifty xmlns=“http://nifty-gui.sourceforge.net/nifty.xsd” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance
xsi:schemaLocation=“http://nifty-gui.sourceforge.net/nifty.xsd http://nifty-gui.sourceforge.net/nifty.xsd”>
<useControls filename=“nifty-default-controls.xml” />
<useStyles filename=“nifty-default-styles.xml” />
<popup id=“badges” controller=“dae.repest.gui.controllers.AchievementController” visibleToMouse=“true” childLayout=“center”>
<panel width=“775px” height=“623px” backgroundImage=“gui_FA/HUD/badges/achievements.png” childLayout=“absolute”>
<control name=“label” x=“760px” y=“0px” text=“X” font=“fonts/comicbook_38.fnt” >
<interact onClick=“ok()”/>
</control>
<control name=“label” text=“Badges” y=“30px” x=“40px” align=“left” font=“fonts/comicbook_38.fnt”/>
<image id=“imgwatch” x=“1%” y=“15%” filename=“gui_FA/HUD/badges/grey.png” childLayout=“absolute” name=“cutiebadge”/>
<image id=“imgwatch” x=“1%” y=“42%” filename=“gui_FA/HUD/badges/grey.png” childLayout=“absolute” />
<image id=“imgwatch” x=“1%” y=“69%” filename=“gui_FA/HUD/badges/grey.png” childLayout=“absolute” />
<image id=“imgwatch” x=“20%” y=“15%” filename=“gui_FA/HUD/badges/grey.png” childLayout=“absolute” />
<image id=“imgwatch” x=“20%” y=“42%” filename=“gui_FA/HUD/badges/grey.png” childLayout=“absolute” />
<image id=“imgwatch” x=“20%” y=“69%” filename=“gui_FA/HUD/badges/grey.png” childLayout=“absolute” />
<image id=“imgwatch” x=“39%” y=“15%” filename=“gui_FA/HUD/badges/grey.png” childLayout=“absolute” />
<image id=“imgwatch” x=“39%” y=“42%” filename=“gui_FA/HUD/badges/grey.png” childLayout=“absolute” />
<image id=“imgwatch” x=“39%” y=“69%” filename=“gui_FA/HUD/badges/grey.png” childLayout=“absolute” />
<image id=“imgwatch” x=“58%” y=“15%” filename=“gui_FA/HUD/badges/grey.png” childLayout=“absolute” />
<image id=“imgwatch” x=“58%” y=“42%” filename=“gui_FA/HUD/badges/grey.png” childLayout=“absolute” />
<image id=“imgwatch” x=“58%” y=“69%” filename=“gui_FA/HUD/badges/grey.png” childLayout=“absolute” />
<image id=“imgwatch” x=“77%” y=“15%” filename=“gui_FA/HUD/badges/grey.png” childLayout=“absolute” />
<image id=“imgwatch” x=“77%” y=“42%” filename=“gui_FA/HUD/badges/grey.png” childLayout=“absolute” />
<image id=“imgwatch” x=“77%” y=“69%” filename=“gui_FA/HUD/badges/grey.png” childLayout=“absolute” />
</panel>
</popup>
</nifty>[/java]

And a controller:

[java]/*

  • To change this template, choose Tools | Templates
  • and open the template in the editor.
    */
    package dae.repest.gui.controllers;

import dae.repest.level.event.UIPartController;
import dae.repest.player.CustomizablePlayer;
import dae.repest.player.InventoryItem;
import dae.repest.player.Player;
import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.controls.Controller;
import de.lessvoid.nifty.elements.Element;
import de.lessvoid.nifty.elements.render.ImageRenderer;
import de.lessvoid.nifty.input.NiftyInputEvent;
import de.lessvoid.nifty.render.NiftyImage;
import de.lessvoid.nifty.screen.Screen;
import de.lessvoid.xml.xpp3.Attributes;
import java.util.Properties;

/**
*

  • @author Koen
    */
    public class AchievementController implements Controller {

    private Screen screen;
    private Nifty nifty;

    @Override
    public void bind(Nifty nifty, Screen screen, Element element, Properties parameter, Attributes controlDefinitionAttributes) {
    this.nifty = nifty;
    this.screen = screen;
    }

    @Override
    public void init(Properties parameter, Attributes controlDefinitionAttributes) {
    }

    @Override
    public void onStartScreen() {
    System.out.println("BADGES ");

     // load or create new image
     NiftyImage img = nifty.getRenderEngine().createImage(screen, "gui_FA/HUD/badges/grey.png", false);
    
     // find old image
     Element niftyElement = nifty.getCurrentScreen().findElementByName("cutiebadge");
    
     // swap old with new image
     niftyElement.getRenderer(ImageRenderer.class).setImage(img);
    

    }

    @Override
    public void onFocus(boolean getFocus) {
    }

    @Override
    public boolean inputEvent(NiftyInputEvent inputEvent) {
    return true;
    }
    }
    [/java]

I’m trying to change and image (as explained in the tutorial). The problem I encounter is that [java]nifty.getCurrentScreen()[/java] returns the screen with id “hud” instead of “badges”.
also when I do : nifty.getscreen(“badges”) I get null and when I do [java]nifty.getAllScreensName()[/java] the badges UI is not in the list.

Why is this and how can it be solved ?

Extra info: The ui is shown when the user presses a button.

You have “badges” set as a popup and not a screen so I would assume that it wouldn’t show up in the screen list.

True (figured that a few hours ago, forgot to post that it is solved)