My Controller Class (NiftyGUI)

Hey everyone, I’ve been doing some reading. On what a NiftyGUI Controller class should look like.
I think I have a decent Controller class:

import com.jme3.material.Material;
import com.jme3.math.Vector3f;
import com.jme3.niftygui.NiftyJmeDisplay;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.screen.Screen;
import de.lessvoid.nifty.controls.Console;
import de.lessvoid.nifty.screen.ScreenController;

public class Controller implements ScreenController {

    protected NiftyJmeDisplay niftDisplay;
    protected Screen screen;
    Nifty nifty;
    Console console;
    boolean optionsMenuVisible = false;

    public static void main(String[] args){

    public void bind(Nifty nifty, Screen screen) {
        System.out.println("bind( " + screen.getScreenId() + ")");
        nifty.getScreen("main").findNiftyControl("console", Console.class);
    public void outputToConsole(String input){
    public void toggleConsole(){
        //page 339
    public void onConsoleCommand(final String id){
        //page 339
    public void toggleOptionsMenu(){

    public void onStartScreen() {

    public void onEndScreen() {

    public void quit(Controller app){


Does anybody have any suggestions? Should I add an initialize method at the top. Should I add a simpleInitApp as well?

What would call it?

Is it in an application? How many applications do you need in your application? (“Yo, dawg…”)

Nifty is pretty tricky to get right even for experienced java developers. If the book is walking you through it then you should follow it exactly. Do not stray from the path because there be dragons there. I thought the book source code was available somewhere.

Also, why does your controller have a main() method? That makes no sense.

yes it is an application. Its just the nick pick stuff like you said. Having a main method in the controller class…So I’m going to assume that this main method belongs to the Nifty AppState class that does have a simpleInitApp.

wait what do you mean by application. I’m not running the controller class file for the output. I’m just storing values. Now for my Nifty AppState class I have a simpleInitApp. Should I add an initialize method to it just for the support? Or does the bind method do all the initializing of the instances

Hi @mack0929 you should maybe start to learn how programming works in general. First of all, learn how to program in Java, code something simple (not a game) and learn from it. Of course all this takes time and effort but it’s worth it and after a while you can proudly return to 3D games. Otherwise it will be tough time for you with a lot of frustration!