Nift Gui Screen not found

So I’m trying to follow the nifty gui tutorial at: https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:nifty_gui_xml_layout, but it’s not working. I have an initHud() method which is called from simpleInitApp():

[java] private void initHud()
{
NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(assetManager, inputManager, audioRenderer, guiViewPort);

    Nifty nifty = niftyDisplay.getNifty();
    
    nifty.fromXml("Interface/startGUI.xml", "start");//, new MySettingsScreen());
    
    guiViewPort.addProcessor(niftyDisplay);

}[/java]

and the startGUI.xml:

[java]<?xml version=“1.0” encoding=“UTF-8”?>
<nifty xmlns=“http://nifty-gui.sourceforge.net/nifty-1.3.xsd” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=“http://nifty-gui.sourceforge.net/nifty-1.3.xsd http://nifty-gui.sourceforge.net/nifty-1.3.xsd”>
<useStlyles filename=“nift-default-styles.xml” />

&lt;screen id="start"&gt;
    &lt;layer id="background" backgroundColor="#003f" childLayout="center"&gt;
        &lt;image filename="" width="100%" height="100%" /&gt;
    &lt;/layer&gt;
    
    &lt;layer id="foreground" childLayour="vertical"&gt;
        &lt;panel id="panel_top" height="25%" width="75%" align="center" childLayout="center"
               backgroundColor="#f008"&gt;  
        &lt;/panel&gt;
        &lt;panel id="panel_mid" height="50%" width="75%" align="center" childLayout="center"
               backgroundColor="#0f08"&gt;  
        &lt;/panel&gt;
        &lt;panel id="panel_bottom" height="25%" width="75%" align="center" childLayout="horizontal"
               backgroundColor="#00f8"&gt;  
          &lt;panel id="panel_bottom_left" height="50%" width="50%" valign="center" childLayout="center" 
               backgroundColor="#44f8"&gt;  
          &lt;/panel&gt;
          &lt;panel id="panel_bottom_right" height="50%" width="50%" valign="center" childLayout="center"
               backgroundColor="#88f8"&gt;  
          &lt;/panel&gt;
        &lt;/panel&gt;
    &lt;/layer&gt;
&lt;/screen&gt;

&lt;screen id="HUD"&gt;
    &lt;layer id="background" backgroundColor="#000f"&gt;
      &lt;!-- ... --&gt;
    &lt;/layer&gt;
    &lt;layer id="foreground" backgroundColor="#0000" childLayout="horizontal"&gt;
        &lt;panel id="panel_top" height="25%" width="75%" align="center" childLayout="center"
                backgroundColor="#f008"&gt;  
        &lt;/panel&gt;
        &lt;panel id="panel_top_right" height="100%" width="15%" childLayout="center"&gt;  
            &lt;control name="label" color="#000" text="123" width="100%" height="100%" /&gt;
        &lt;/panel&gt;
        &lt;panel id="panel_mid" height="50%" width="75%" align="center" childLayout="center"
                backgroundColor="#0f08"&gt;  
        &lt;/panel&gt;
        &lt;panel id="panel_bottom" height="25%" width="75%" align="center" childLayout="horizontal"
                backgroundColor="#00f8"&gt;  
            &lt;panel id="panel_bottom_left" height="50%" width="50%" valign="center" childLayout="center" 
                backgroundColor="#44f8"&gt;  
            &lt;/panel&gt;
            &lt;panel id="panel_bottom_right" height="50%" width="50%" valign="center" childLayout="center"
                backgroundColor="#88f8"&gt;  
            &lt;/panel&gt;
        &lt;/panel&gt;
    &lt;/layer&gt;        
&lt;/screen&gt;

</nifty>
[/java]

But when I try to run the program, nothing happens, my output looks like this:

Oct 14, 2014 9:25:09 PM de.lessvoid.nifty.Nifty gotoScreenInternal WARNING: screen [start] not found Oct 14, 2014 9:25:09 PM de.lessvoid.nifty.Nifty initialize WARNING: An event service by the name NiftyEventBusalready exists. Perhaps multiple threads tried to create a service about the same time? org.bushe.swing.event.EventServiceExistsException: An event service by the name NiftyEventBusalready exists. Perhaps multiple threads tried to create a service about the same time? at org.bushe.swing.event.EventServiceLocator.setEventService(EventServiceLocator.java:123) at de.lessvoid.nifty.Nifty.initalizeEventBus(Nifty.java:222) at de.lessvoid.nifty.Nifty.initialize(Nifty.java:202) at de.lessvoid.nifty.Nifty.<init>(Nifty.java:143) at com.jme3.niftygui.NiftyJmeDisplay.<init>(NiftyJmeDisplay.java:159) at menus.StartMenu.initialize(StartMenu.java:27) at com.jme3.app.state.AppStateManager.initializePending(AppStateManager.java:251) at com.jme3.app.state.AppStateManager.update(AppStateManager.java:281) at com.jme3.app.SimpleApplication.update(SimpleApplication.java:239) at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151) at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185) at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:228) at java.lang.Thread.run(Thread.java:744)

Oct 14, 2014 9:25:09 PM de.lessvoid.nifty.Nifty gotoScreenInternal
WARNING: screen [start] not found
BUILD SUCCESSFUL (total time: 4 seconds)

I’m not sure what I’m missing, if anyone can help, it would be greatly appreciated.

Try to add the scene processor before “.fromXML”.
You should also consider this:
[java]
// If u dont want to use DefaultScreenController
nifty.fromXml(screenPath, screenId, screenController);
// Try below
nifty.gotoScreen(screenId);
[/java]

Maybe it helps :wink:

It also seems like you are adding the processor twice or initializing your HUD twice. You should do some debugging to figure that out. Like, the first ‘start’ warning happens before your initialization code (or your initialization code is running twice).

First off sorry, I meant to post this in the GUI section of the forum, but I’ve been having trouble with this site the past couple of nights.

Secondly, I’ve used S.O.P lines in my simpleInitApp() method and my initHud() as follows:

[java] public void simpleInitApp()
{
//stateManager.attach(menu);

    System.out.println("MouseInput");
    mouseInput.setCursorVisible(true);
    System.out.println("flyCam");
    flyCam.setEnabled(false);
    
    System.out.println("bulletAppState");
    bulletAppState = new BulletAppState();
    System.out.println("Add bulletAppState to stateManager");
    stateManager.attach(bulletAppState);
    
    System.out.println("initHud()");
    initHud();
    System.out.println("initFilter()");
    //initFilter(); 
    System.out.println("initLevel()");
    //initLevel();
    System.out.println("initLight()");
    //initLight();
    System.out.println("initPlayer()");
    initPlayer();
    System.out.println("initMouse");
    initMouse();
    System.out.println("Add CollisionListener");
    bulletAppState.getPhysicsSpace().addCollisionListener(this);
    
}[/java]

[java] private void initHud()
{
System.out.println(“Setup nifty.”);
NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(assetManager, inputManager, audioRenderer, guiViewPort);

    nifty = niftyDisplay.getNifty();
    
    nifty.fromXml("Interface/startGUI.xml", "start", this);//, new MySettingsScreen());
    //nifty.gotoScreen("start");
    guiViewPort.addProcessor(niftyDisplay);
    
}[/java]

When I run the program, the output looks like this:

MouseInput flyCam bulletAppState Add bulletAppState to stateManager initHud() Setup nifty. initFilter() Oct 15, 2014 1:39:48 PM de.lessvoid.nifty.Nifty gotoScreenInternal initLevel() initLight() WARNING: screen [start] not found initPlayer() initMouse

Every time I comment out a method call in my simpleInitApp(), the warning message pops up under the next S.O.P line. I’m not accessing nifty from anywhere else but initHud() so I don’t know what, if anything is effecting it in the other methods. I’ll post the code just the same though:

[java] private void initLight()
{
AmbientLight al = new AmbientLight();
al.setColor(ColorRGBA.White.mult(12.3f));
rootNode.addLight(al);

    DirectionalLight dl = new DirectionalLight();
    dl.setColor(ColorRGBA.White);
    dl.setDirection(new Vector3f(0, 2, -10).normalizeLocal());
    rootNode.addLight(dl);
}

private void initLevel()
{
    //System.out.println("Initializing Level...");
    level = new lvlGen(assetManager);
    //System.out.println("Attaching level...");
    level.getLevel().setLocalTranslation(0,0,0);
    rootNode.attachChild(level.getLevel());
    //System.out.println("level = " + level);
}

private void initFilter() 
{
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    BloomFilter bloom = new BloomFilter(BloomFilter.GlowMode.Objects);
    fpp.addFilter(bloom);
    viewPort.addProcessor(fpp);
}[/java]

What is menus.StartMenu?

…from your stack trace it seems to be initializing nifty again.

@pspeed said: What is menus.StartMenu?

…from your stack trace it seems to be initializing nifty again.

That was something leftover from an earlier attempt at a HUD, I had a line that I forgot to delete:
[java]StartMenu menu = new StartMenu();[/java]
I’ve deleted that, and also added some new S.O.P. lines to initHud():
[java] private void initHud()
{
System.out.println(“Setup nifty.”);
NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(assetManager, inputManager, audioRenderer, guiViewPort);

    System.out.println("niftyDisplay");
    nifty = niftyDisplay.getNifty();
    
    System.out.println("fromXml");
    nifty.fromXml("Interface/startGUI.xml", "start", this);
    //nifty.gotoScreen("start");
    System.out.println("addProcessor");
    guiViewPort.addProcessor(niftyDisplay);
    System.out.println("Done with nifty");

    System.out.println("Done with initHud");
}[/java]

Unfortunately, I’m still getting this output:

[java]MouseInput
flyCam
bulletAppState
Add bulletAppState to stateManager
initHud()
Setup nifty.
niftyDisplay
fromXml
addProcessor
Done with nifty
Oct 15, 2014 11:17:28 PM de.lessvoid.nifty.Nifty gotoScreenInternal
Done with initHud
initFilter()
WARNING: screen [start] not found
initLevel()
initLight()
initPlayer()
initMouse
Add CollisionListener
BUILD SUCCESSFUL (total time: 3 seconds)[/java]

I don’t know why the warning is showing up between the “initFilter()” and “initLevel()” S.O.P lines, there is nothing happening between those lines of code.

@MKthot said: I don't know why the warning is showing up between the "initFilter()" and "initLevel()" S.O.P lines, there is nothing happening between those lines of code.

Actually, after running the program a few times without changing any code, the warning is now showing up here instead:
[java]Done with initHud
WARNING: screen [start] not found
initFilter()[/java]

Is it a delayed response? Between my last posting of the output and this one, I haven’t changed anything in the code.

Well, we can’t hope to help if we are provided with inaccurate stack traces. Are you no longer getting that stack trace then?

Anyway, this likely doesn’t have anything to do with your start screen problem unless there is something loading a file with no start screen and trying to go to it. You could try renaming your XML and see if you get an error that it can’t be found… just to be sure you are using the one you think you are. And/or boil your code down to a simple test case to eliminate all other possibilities. It’s also easier for the folks who use nifty to help when there aren’t a lot of moving and changing parts.

@pspeed said: Well, we can't hope to help if we are provided with inaccurate stack traces. Are you no longer getting that stack trace then?

No, I haven’t been getting that stack trace since I removed the line
[java]StartMenu menu = new StartMenu();[/java]
Since then I’ve just been getting the outputs that I have been showing in my posts since.

I’ve tried renaming the xml file itself without changing the path in the code, and I end up getting an AssetNotFoundException when I do. I get the same results if I change the name in the code and leave the xml file’s name the same. So it would appear to finding the file, but for some reason it can’t find the “start” screen. I haven’t changed my file since I posted it earlier. I’ve gone over what the tutorial’s xml file looks like as well as a few other examples, and I can’t find anything wrong with it.

Well, at least you’ve narrowed it down. Hopefully someone who actually uses nifty can tell you what you may have missed. I stopped using it like 2+ years ago so I’m not sure.

Weird, maybe try to set the default controls in your xml file:

[java] <useControls filename=“nifty-default-controls.xml” />[/java]

if it doesn’t work either i’am out of solutions

Try correct spelling of ‘Styles’ - might make a difference

useStlyles filename=”nift-default-styles.xml”

@jmaasing said: Try correct spelling of 'Styles' - might make a difference

useStlyles filename=”nift-default-styles.xml”

Well I managed to miss that every time I went through the file. It made a difference, but now I get an IllegalStateExcption: No loader registered for type “” message when I run the program:

[java]
Oct 16, 2014 1:32:34 PM de.lessvoid.nifty.screen.Screen <init>
WARNING: Missing ScreenController for screen [start] using DefaultScreenController() instead but this might not be what you want.
Oct 16, 2014 1:32:34 PM com.jme3.app.Application handleError
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.RuntimeException: java.lang.IllegalStateException: No loader registered for type “”
at de.lessvoid.nifty.Nifty.loadFromFile(Nifty.java:577)
at de.lessvoid.nifty.Nifty.fromXml(Nifty.java:480)
at mygame.Main.initHud(Main.java:148)
at mygame.Main.simpleInitApp(Main.java:115)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:226)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:130)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:207)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.IllegalStateException: No loader registered for type “”
at com.jme3.asset.ImplHandler.aquireLoader(ImplHandler.java:198)
at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:271)
at com.jme3.asset.DesktopAssetManager.loadTexture(DesktopAssetManager.java:346)
at com.jme3.niftygui.RenderImageJme.<init>(RenderImageJme.java:55)
at com.jme3.niftygui.RenderDeviceJme.createImage(RenderDeviceJme.java:166)
at de.lessvoid.nifty.render.NiftyImageManager.addImage(NiftyImageManager.java:127)
at de.lessvoid.nifty.render.NiftyImageManager.registerImage(NiftyImageManager.java:28)
at de.lessvoid.nifty.render.NiftyRenderEngineImpl.createImage(NiftyRenderEngineImpl.java:172)
at de.lessvoid.nifty.loaderv2.types.apply.ApplyRendererImage.apply(ApplyRendererImage.java:37)
at de.lessvoid.nifty.elements.Element.initializeFromAttributes(Element.java:434)
at de.lessvoid.nifty.loaderv2.types.ElementType.applyAttributes(ElementType.java:218)
at de.lessvoid.nifty.loaderv2.types.ElementType.applyStandard(ElementType.java:172)
at de.lessvoid.nifty.loaderv2.types.ElementType.create(ElementType.java:144)
at de.lessvoid.nifty.loaderv2.types.ElementType.applyChildren(ElementType.java:251)
at de.lessvoid.nifty.loaderv2.types.ElementType.applyStandard(ElementType.java:175)
at de.lessvoid.nifty.loaderv2.types.ElementType.create(ElementType.java:144)
at de.lessvoid.nifty.loaderv2.types.ScreenType.create(ScreenType.java:80)
at de.lessvoid.nifty.loaderv2.types.NiftyType.create(NiftyType.java:137)
at de.lessvoid.nifty.Nifty.loadFromFile(Nifty.java:570)
… 7 more

BUILD SUCCESSFUL (total time: 5 seconds)[/java]

Am I forgetting to do something else in the xml file? Or is it in the java code?