Missing ScreenContoller


I started using nifty and I always get the following error:

INFO: Missing ScreenController for screen [null] using DefaultScreenController() instead but this might not be what you want.

However, I created Nifty object like this:

[java]nifty.fromXml("src/resources/gui/start.xml", "start", new NiftyScreenController());[/java]

NiftyScreenController is a class that implements ScreenController.

Do you have a screen named “start” at all? I am wondering why the screen is null in the output.

Yes, my xml file starts like that:

[xml]<?xml version="1.0" encoding="UTF-8"?>


<screen id="start" controller="org.gui.NiftyScreenController">


put that in [xml][/xml] tags…

According the error, it’s not screen “start” that has the problem. Is that the only screen in the file?

Yes, it is. Could it be that I have to implement the overwritten method

[java]public void bind(Nifty arg0, Screen arg1)[/java]

in my class NiftyScreenController because I didn’t?

Make sure your controller’s path is right:


This looks a bit dubious to me since you’re using the following for your nifty screen.


There are no reasons to have them together, but it’s easier and less confusing when they are.

Can you post your screen controller?

Ok, here is my controller:

[java]package org.gui;

import de.lessvoid.nifty.Nifty;

import de.lessvoid.nifty.screen.Screen;

import de.lessvoid.nifty.screen.ScreenController;

import de.lessvoid.nifty.spi.input.InputSystem;

import de.lessvoid.nifty.spi.render.RenderDevice;

import de.lessvoid.nifty.spi.sound.SoundDevice;

import de.lessvoid.nifty.tools.TimeProvider;

public class NiftyScreenController implements ScreenController {

private Nifty nifty;

private static final boolean DEBUG = true;

public NiftyScreenController(Nifty nifty) {

this.nifty = nifty;



public void bind(Nifty arg0, Screen arg1) {

// TODO implement method



public void onEndScreen() {

if(DEBUG)System.out.println(“On end screen”);



public void onStartScreen() {

if(DEBUG)System.out.println(“On start screen”);


public void showSettings() {

if(DEBUG)System.out.println(“Show Settings”);


public void showMultiplayer() {


public void quit() {





This is how I create the Nifty object etc.:

[java]NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(assetManager,




nifty = niftyDisplay.getNifty();

try {


NiftyScreenController nsc = new NiftyScreenController(nifty);

nifty.fromXml(“src/org/gui/start.xml”, “start”, nsc);

// attach the nifty display to the gui view port as a processor


} catch (Exception e) {



start.xml is in the same directory now, so the first lines of start.xml are:

[xml]<?xml version=“1.0” encoding=“UTF-8”?>


<screen id=“start” controller=“src.org.gui.NiftyScreenController”>[/xml]

Moreover, the error goes on like that:

INFO: Missing ScreenController for screen [null] using DefaultScreenController() instead but this might not be what you want.

org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element ‘nifty’.

at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)

at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131)

at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384)

at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318)

at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1887)

at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:685)

at com.sun.org.apache.xerces.internal.jaxp.validation.DOMValidatorHelper.beginNode(DOMValidatorHelper.java:273)

at com.sun.org.apache.xerces.internal.jaxp.validation.DOMValidatorHelper.validate(DOMValidatorHelper.java:240)

at com.sun.org.apache.xerces.internal.jaxp.validation.DOMValidatorHelper.validate(DOMValidatorHelper.java:186)

at com.sun.org.apache.xerces.internal.jaxp.validation.ValidatorImpl.validate(ValidatorImpl.java:100)

at javax.xml.validation.Validator.validate(Validator.java:127)

at de.lessvoid.nifty.loaderv2.NiftyLoader.validate(NiftyLoader.java:85)

at de.lessvoid.nifty.loaderv2.NiftyLoader.validateNiftyXml(NiftyLoader.java:64)

at de.lessvoid.nifty.Nifty.validateXml(Nifty.java:412)

at org.Game.loadGui(Game.java:117)

at org.Game.simpleInitApp(Game.java:79)

at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:218)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:136)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:193)

at java.lang.Thread.run(Thread.java:619)

You need an empty constructor for your ScreenController.

I replaced the constructor with an empty one, but it still doesn’t work.

It seems the complaint is that the nifty tag is “missing”. Make sure to close the nifty XML tag.

Alternatively, you can use the complete nifty tag. Not sure if that’ll make a difference though.


<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”>

[… other stuff here …]



That paste didn’t go too well… Just use the palette to generate a new nifty XML and copy the nifty tag. It’ll be easier that way…

pk123 said:
I replaced the constructor with an empty one, but it still doesn't work.

You didn't need to replace the old one. Just add an empty constructor. Nifty needs that when creating the screens. Just FYI.

What is the right XML now? Because this:


Is very much wrong. It should be org.gui.NiftyScreenController.

I get the feeling like we are never seeing the whole picture and what we do keeps changing in small ways.

This is my file start.xml now:

[xml]<?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”&gt>

<screen id=“start” controller=“org.gui.NiftyScreenController”>

<layer id=“layerMain” backgroundColor="#ee0" childLayout=“center”>

<panel id=“menues” backgroundColor="#ef00ef" childLayout=“vertical” height=“100%” width=“50%” align=“center”>

<label id=“butSingle” backgroundColor="#ee2" text=“Singleplayer” width=“90%” height=“20%”>

<interact onClick=“showSingleplayer()”/>


<label id=“butMulti” backgroundColor="#ee2" text=“Multiplayer” width=“90%” height=“20%”>

<interact onClick=“showMultiplayer()”/>


<label id=“butSettings” backgroundColor="#ee2" text=“Settings” width=“90%” height=“20%”>

<interact onClick=“showSettings()”/>


<label id=“butQuit” backgroundColor="#ee2" text=“Quit” width=“90%” height=“20%”>

<interact onClick=“quit()”/>




<layer id=“layerSettings” backgroundColor="#ee0" childLayout=“vertical”>


<layer id=“layerSingle” backgroundColor="#ee0" childLayout=“vertical”>


<layer id=“layerMulti” backgroundColor="#ee0" childLayout=“vertical”>




However, I get the following error:

[Fatal Error] :2:79: Element type “nifty” must be followed by either attribute specifications, “>” or “/>”.

org.xml.sax.SAXParseException: Element type “nifty” must be followed by either attribute specifications, “>” or “/>”.

so there is a mistake at the end of the second line, but I couldn’t fix it.

So many errors. :stuck_out_tongue:

First, a couple of things.

[xml]<label …>[/xml]

Doesn’t exist anymore. Instead use:

[xml]<control name=“label” … >[/xml]

For coloors, use either the short formulation : #RGBA (for Red Green Blue Alpha) assigning 1 or 2 hexadecimal digit for each color and alpha, but you can’t discard the alpha. So in short, either #RRGGBBAA or #RGBA. The first is more concise but if you’re looking for a particular color it might be better to use the long format.

That screen works here although I suspect the colors are wrong. Bright yellow is hard on the eyes. :wink:


<screen id=“start” controller=“mygame.NiftyTest”>

<layer id=“layerMain” backgroundColor="#ee00" childLayout=“center”>

<panel id=“menues” backgroundColor="#ef00efff" childLayout=“vertical” height=“100%” width=“50%” align=“center”>

<control name=“label” id=“butSingle” backgroundColor="#000f" text=“Singleplayer” width=“90%” height=“20%”>

<interact onClick=“showSingleplayer()”/>


<control name=“label” id=“butMulti” backgroundColor="#000f" text=“Multiplayer” width=“90%” height=“20%”>

<interact onClick=“showMultiplayer()”/>


<control name=“label” id=“butSettings” backgroundColor="#000f" text=“Settings” width=“90%” height=“20%”>

<interact onClick=“showSettings()”/>


<control name=“label” id=“butQuit” backgroundColor="#000f" text=“Quit” width=“90%” height=“20%”>

<interact onClick=“quit()”/>




<layer id=“layerSettings” backgroundColor="#ee0f" childLayout=“vertical”>


<layer id=“layerSingle” backgroundColor="#ee0f" childLayout=“vertical”>


<layer id=“layerMulti” backgroundColor="#ee0f" childLayout=“vertical”>




As for the first line, with the pasting bug it’s pretty hard to copy the right line. Here’s the data though.

xmlns=“The protocol here : nifty-gui.sourceforge.net/nifty-1.3.xsd

xmlns:xsi=“The protocol here : www.w3.org/2001/XMLSchema-instance

xsi:schemaLocation=“The protocol here : nifty-gui.sourceforge.net/nifty-1.3.xsd

Replace "The protocol here : " with “http://”

Hopefully that’ll fix your problem. Here it is loading. Can’t see anything, but that’s as far as I’ll go. :wink:

Sorry for the terrible colours, they were the only codes I knew :slight_smile:

Does the following mean, that I don’t need any quotes around this attribute?:

[Fatal Error] :2:14: Open quote is expected for attribute “{1}” associated with an element type “xmlns”

Anyway, I don’t know if that’ll fix it, but thanks a lot for your time.

I think that should work… Let’s try this:

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

The above is the whole nifty line without the “<” and “>”.

sigh FFS I hate that post parser.

Each attribute needs the name, xmlns for example, then its value after the equals in quotes. It’s like any XML file really or HTML or CSS.