Black Screen Using NiftyGUI w/ Application and AppState


I’m an older JME1/2 developer who is trying to start using JME3 (I think what you have done with it is AWESOME by the way).

I’ve installed the jMonkeyPlatform and have created an XML file from the tutorials on NiftyGUI. I am trying to build an Application and here is the very top overview of what I want

+Main (extends Application, has many AppStates)

  • MainMenuState (extends AppState)

    … others including Play and About AppStates …

    Here is my XML file for my GUI:

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

    <nifty xmlns="" xmlns:xsi="" xsi:schemaLocation="">

    <screen id="start" controller="com.trussellgroupllc.legionaire.gui.MainMenuController">

    <useControls filename="nifty-default-controls.xml" />

    <layer id="layer" backgroundColor="#000000" childLayout="center">

    <panel id="bgPanel" height="100%" width="100%" align="center" valign="center" style="nifty-panel-simple">


    <panel id="buttonpanel" height="80%" width="40%" align="center" valign="center" style="nifty-panel">

    <control id="startGameBtn" label="Start Game" />

    <control id="settingsBtn" label="Settings" />

    <control id="aboutBtn" label="About Legionaire" />

    <control id="quitBtn" label="Quit Legionaire" />






    Here is my Application extension:


    package com.trussellgroupllc.legionaire;


    import com.jme3.system.AppSettings;

    import com.jme3.system.Timer;

    import com.trussellgroupllc.legionaire.appstates.MainMenuState;

    import com.trussellgroupllc.legionaire.logging.LoggingManager;

  • test
  • @author normenhansen


    public class Main extends Application {

    MainMenuState mainMenuState;

    public static void main(String[] args) {

    Main app = new Main();




    public void start() {

    settings = new AppSettings(true);






    public void initialize() {

    super.initialize(); //Call Super’s Init


    LoggingManager.getInstance().logStd("+=== Application Initialized ===+");

    LoggingManager.getInstance().logStd(“t(TrussellGroup, L.L.C. v0.01)”);

    mainMenuState = new MainMenuState();

    stateManager.attach(mainMenuState);//Load our Main Menu into the AppStateManager



    public void update() {


    float tpf = timer.getTimePerFrame();






    public void destroy() {




    public Timer getTimer() {

    return timer;




    And my AppState extension:


    package com.trussellgroupllc.legionaire.appstates;




    import com.jme3.math.Vector3f;

    import com.jme3.niftygui.NiftyJmeDisplay;

    import com.jme3.renderer.RenderManager;

    import com.trussellgroupllc.legionaire.logging.LoggingManager;

    import de.lessvoid.nifty.Nifty;


  • @author Tyler


    public class MainMenuState implements AppState {

    Application appRef;

    AppStateManager stateManagerRef;

    boolean fullinit = false, active = false;

    String gameTitleText, aboutText, startBtnText, stgsBtnText, quitBtnText, abtBtnText;

    NiftyJmeDisplay niftyDisplay;

    Nifty nifty; //Our Main GUI Control

    public void initialize(AppStateManager stateManager, Application app) {

    this.appRef = app;

    this.stateManagerRef = stateManager;

    gameTitleText = “Leginonaire”;

    aboutText = “TrussellGroup, L.L.C. v0.01”;

    startBtnText = “Start New Game”;

    stgsBtnText = “Options”;

    quitBtnText = “Quit Legionaire”;

    abtBtnText = “About Legionaire”;

    niftyDisplay = new NiftyJmeDisplay(

    app.getAssetManager(), app.getInputManager(), app.getAudioRenderer(), app.getGuiViewPort());

    nifty = niftyDisplay.getNifty();

    nifty.fromXml(“Interface/MainMenuGui.xml”, “start”);



    fullinit = true;


    public boolean isInitialized() {

    return fullinit;


    public void setActive(boolean active) {

    if (!isInitialized()) {

    System.err.print(“MainMenuState could not be activated because it is not initialized.”);

    } else { = true;



    public boolean isActive() {



    public void stateAttached(AppStateManager stateManager) {

    LoggingManager.getInstance().logStd(“MainMenuState attached to AppStateManager.”);


    public void stateDetached(AppStateManager stateManager) {

    LoggingManager.getInstance().logStd(“MainMenuState removed from AppStateManager.”);


    public void update(float tpf) {




    public void render(RenderManager rm) {}

    public void postRender() {}

    public void cleanup() {





    But I just see a black screen. I’m sure it’s something that I’m not rendering, but like I said I’m unsure because I haven’t used much JME3. I looked through all of the Documentation, but there just wasn’t enough to get me started. Thanks, guys!

Hmmm… Cant try it atm but it looks ok… I suggest a) trying with the default niftygui xml file (New File…) and b) try using a SimpleApplication base.



<control id=“startGameBtn” label=“Start Game” />

<control id=“settingsBtn” label=“Settings” />

<control id=“aboutBtn” label=“About Legionaire” />

<control id=“quitBtn” label=“Quit Legionaire” />


You are telling nifty to add controls without telling nifty what kind of controls. This may be what’s causing the problem. Without being able to test it atm. I can’t be 100% sure though.

If you need buttons, try adding name=“button” to the control.

1 Like

ractoc is right, the name attribute is required for the control tag.


the Nifty instance supports optional xml validation. You can just call: nifty.validateXml() with the xml file to validate and it will probably complain about incorrect or missing tags! :slight_smile:


This is something the code completion in jMP already provides I think. This time it’s in the XSD:

[xml] <xs:complexType name=“controlType”>


<xs:extension base=“elementType”>

<xs:attribute name=“name” type=“xs:string”></xs:attribute>

<xs:attribute name=“onChange” type=“xs:string”></xs:attribute> <!-- this is not supported anymore in Nifty 1.3 -->

<xs:anyAttribute processContents=“skip” namespace="##any" />




That “onChange” has to be removed. It’s not supported any more. I’ve missed that. D’oh!