anchor.diff:  }
   
   ----
  -
  -[source,java]
  -----
  -/*
  - * To change this template, choose Tools | Templates
  - * and open the template in the editor.
  - */
  +.Complete BaseAppState file
  +[source,java]
  +----
   package mygame;
   
   import com.jme3.app.Application;
  -import com.jme3.app.state.AbstractAppState;
  -import com.jme3.app.state.AppStateManager;
  +import com.jme3.app.state.BaseAppState;
   import de.lessvoid.nifty.Nifty;
   import de.lessvoid.nifty.screen.Screen;
   import de.lessvoid.nifty.screen.ScreenController;
   
  -public class MyStartScreen extends AbstractAppState implements ScreenController {
  -    
  -    @Override
  -    public void initialize(AppStateManager stateManager, Application app) {
  -        super.initialize(stateManager, app);
  -        //TODO: initialize your AppState, e.g. attach spatials to rootNode
  -        //this is called on the OpenGL thread after the AppState has been attached
  -    }
  -    
  -    @Override
  -    public void update(float tpf) {
  -        //TODO: implement behavior during runtime
  -    }
  -    
  -    @Override
  -    public void cleanup() {
  -        super.cleanup();
  -        //TODO: clean up what you initialized in the initialize method,
  -        //e.g. remove all spatials from rootNode
  -        //this is called on the OpenGL thread after the AppState has been detached
  -    }
  -
  -    public void bind(Nifty nifty, Screen screen) {
  -        throw new UnsupportedOperationException("Not supported yet.");
  -    }
  -
  -    public void onStartScreen() {
  -        throw new UnsupportedOperationException("Not supported yet.");
  -    }
  -
  -    public void onEndScreen() {
  -        throw new UnsupportedOperationException("Not supported yet.");
  -    }
  +public class MyStartScreen extends BaseAppState implements ScreenController {
  +
  +  @Override
  +  protected void initialize(Application app) {
  +      //It is technically safe to do all initialization and cleanup in the
  +      //onEnable()/onDisable() methods. Choosing to use initialize() and
  +      //cleanup() for this is a matter of performance specifics for the
  +      //implementor.
  +      //TODO: initialize your AppState, e.g. attach spatials to rootNode
  +  }
  +
  +  @Override
  +  protected void cleanup(Application app) {
  +      //TODO: clean up what you initialized in the initialize method,
  +      //e.g. remove all spatials from rootNode
  +  }
  +
  +  //onEnable()/onDisable() can be used for managing things that should
  +  //only exist while the state is enabled. Prime examples would be scene
  +  //graph attachment or input listener attachment.
  +  @Override
  +  protected void onEnable() {
  +      //Called when the state is fully enabled, ie: is attached and
  +      //isEnabled() is true or when the setEnabled() status changes after the
  +      //state is attached.
  +  }
  +
  +  @Override
  +  protected void onDisable() {
  +      //Called when the state was previously enabled but is now disabled
  +      //either because setEnabled(false) was called or the state is being
  +      //cleaned up.
  +  }
  +
  +  @Override
  +  public void update(float tpf) {
  +      //TODO: implement behavior during runtime
  +  }
  +
  +  /**
  +   * Bind this ScreenController to a screen. This happens right before the
  +   * onStartScreen STARTED and only exactly once for a screen!
  +   * @param nifty nifty
  +   * @param screen screen
  +   */
  +  @Override
  +  public void bind(Nifty nifty, Screen screen) {
  +      throw new UnsupportedOperationException("Not supported yet.");
  +  }
  +
  +  /**
  +   * called right after the onStartScreen event ENDED.
  +   */
  +  @Override
  +  public void onStartScreen() {
  +      throw new UnsupportedOperationException("Not supported yet.");
  +  }
  +
  +  /**
  +   * called right after the onEndScreen event ENDED.
  +   */
  +  @Override
  +  public void onEndScreen() {
  +      throw new UnsupportedOperationException("Not supported yet.");
  +  }
   }
   
   ----
  
positive.code: 
  [source,java]
  ----
  
    nifty.addScreen("start", new ScreenBuilder("start") {{
        controller(new mygame.MyStartScreen())}});
  
  ----
  
  Now the Java class `MyStartScreen` and this +++<abbr title="Graphical User Interface">GUI</abbr>+++ screen (`start`) are connected. For this example you can also connect the `hud` screen to MyStartScreen.
  
  
  == Make GUI and Java Interact
  
  
negative.code: 
  The startGame() example simply switches the +++<abbr title="Graphical User Interface">GUI</abbr>+++ to the `hud` screen when the user clicks Start. Of course, in a real game, you would perform more steps here: Load the game level, switch to in-game input and navigation handling, set a custom `running` boolean to true, attach custom in-game AppStates – and lots more.
  
  The quitGame() example shows that you have access to the Application object because you made the ScreenController extend BaseAppState.
  
  
  === GUI Gets Return Value from Java Method
  
  When the Nifty +++<abbr title="Graphical User Interface">GUI</abbr>+++ is initialized, you can get data from Java. In this example, the Java class `getPlayerName()` in `MyStartScreen` defines the Text that is displayed in the textfield before the words `'s Cool Game`.
  
  First define a Java method in the screen controller, in this example, `getPlayerName()`.
  
  