Can't see GUI on game initialize?

For reference, I’m using Lemur. Basically, I’ve gotten the GUI to work in plenty of places, but for some reason it doesn’t show up here. On initialize of the actual game (upon hitting “play”), the function guiSetup is called, which just builds the gui and attaches it to the guiNode. Just to start, the gui code is exactly the same as the pause gui (though it will become the HUD/controls). I’ve gone through the debugger, and I see the state initialized, the guiNode fetched, the guiSetup function runs, the Lemur Container layout is attached, along with its three buttons, and the game runs. But there is no GUI there. Have I hidden it somehow? No cleanup or enabled(false) calls are being made, as far as I could see, and the location of the container placement works just fine for the pause state. Here’s what I’ve written:

    public GamePlayState(int wwidth, int wheight){
        width = wwidth;
        height = wheight;
    }
    private boolean loading = false;
    
    @Override
    public void initialize(AppStateManager stateManager, Application app) {
        super.initialize(stateManager, app);

        System.out.println("INIT");
        // Initializes main variables
        this.app = ((SimpleApplication)app);
        rootNode = ((SimpleApplication)app).getRootNode();
        guiNode = ((SimpleApplication)app).getGuiNode();  // !!!
        assetManager = ((SimpleApplication)app).getAssetManager();
        inputManager = ((SimpleApplication)app).getInputManager();
        flyCam = ((SimpleApplication)app).getFlyByCamera();
        cam = ((SimpleApplication)app).getCamera();
        bas = stateManager.getState(BulletAppState.class);
        

       // bunch of setup that works fine imo ...

        
        rootNode.attachChild(track);
        
        // Camera setup
        
        camSetup(false);

        guiSetup(); // !!!

       // other stuff that works fine imo
}

private void guiSetup(){
        
//        guiNode.addControl(new InGameGUIControl(input));


        System.out.println(width);
        System.out.println(height);

        BitmapFont myFont = app.getAssetManager().loadFont("Interface/Fonts/PerfectDark(BRK).fnt");


        GuiGlobals.initialize(app);
        // Load the 'glass' style
//        BaseStyles.loadGlassStyle();

        // Set 'glass' as the default style when not specified
//        GuiGlobals.getInstance().getStyles().setDefaultStyle("glass");
        Styles styles = GuiGlobals.getInstance().getStyles();
        Attributes attrs;



    // My styles 

    QuadBackgroundComponent bg = new QuadBackgroundComponent(ColorRGBA.Blue);
//    TbtQuadBackgroundComponent realborder = TbtQuadBackgroundComponent.create(assetManager.loadTexture("Textures/test9patchtex.png"), 1, 5,5, 234,234,0,false);
    TbtQuadBackgroundComponent realborder = TbtQuadBackgroundComponent.create(app.getAssetManager().loadTexture("Textures/GUI/test_blur_patch.png"), 1, 39,39, 256-39,256-39,1,false);
//    TbtQuadBackgroundComponent realborder = TbtQuadBackgroundComponent.create(assetManager.loadTexture("Textures/controls_button.png"), 1,35,35, 342,158,0,false);
//    TbtQuadBackgroundComponent realbg = TbtQuadBackgroundComponent.create(assetManager.loadTexture("Textures/inflicted.png"), 1, 10,10, 229,229,0,false);
    QuadBackgroundComponent realbg = new QuadBackgroundComponent(ColorRGBA.DarkGray);
        QuadBackgroundComponent pink = new QuadBackgroundComponent(ColorRGBA.Pink, 10, 10);
                
                


    realbg.setMargin(10, 10);

    float em = (float)width/100;

        attrs = styles.getSelector("container", null);
        attrs.set("fontSize", 5 * em);
            attrs.set("background", realborder);
            attrs.set("font", myFont);


        attrs = styles.getSelector("button", null);
        attrs.set("fontSize", 5 * em);
            attrs.set("border", realborder);
            attrs.set("font", myFont);

        attrs = styles.getSelector("panel", null);
            attrs.set("fontSize", 5 * em);
            attrs.set("border", realborder);
            attrs.set("font", myFont);

    // Actual GUI



        Container pauseLayout = new Container();
        guiNode.attachChild(pauseLayout);
           pauseLayout.setLocalTranslation((float)width * 0.4f, 0.7f * (float)height, -1);
//                   pauseLayout.setLocalTranslation(10,10, 0);

        Button resume = new Button("resume");
    resume.addClickCommands(new Command<Button>(){
        @Override
        public void execute(Button source){
                        setEnabled(false);
                        app.getStateManager().detach(app.getStateManager().getState(PauseState.class));
                        
                        

                        

                }
    });
        
        Button restart = new Button("restart");
    restart.addClickCommands(new Command<Button>(){
        @Override
        public void execute(Button source){
                        setEnabled(false);
                        app.getStateManager().detach(app.getStateManager().getState(PauseState.class));
                         


                }
    });
        
        Button quit = new Button("Quit");
    quit.addClickCommands(new Command<Button>(){
        @Override
        public void execute(Button source){
                        setEnabled(false);
                        app.getStateManager().detach(app.getStateManager().getState(PauseState.class));
                          



                        

                }
    });
        

        pauseLayout.addChild(resume);
        pauseLayout.addChild(restart);
        pauseLayout.addChild(quit);
        pauseLayout.scale(0.8f);

        
      
    }

I don’t see where you are attaching pauseLayout to something visible. Something like…

getContentPane().add(pauseLayout);

OK. your node is not really GUI but, I don’t see you putting anything it a visible frame, panel, etc.

this line:

guiNode.attachChild(pauseLayout);

should attach the pauseLayout to the guiNode, and these:

        pauseLayout.addChild(resume);
        pauseLayout.addChild(restart);
        pauseLayout.addChild(quit);

populate the layout

I’m not even sure how that compiles. The Container should be a Panel, JPanel , Applet, JApplet, etc that is visible in the 2D world. Then the Container holds the ctx.getCanvas() this you add to your layout.

JFrame window = new JFrame();
window.getContentPane().add(ctx.getCanvas());
window.getContentPane().add(pauseLayout);

What is your Container?
EDIT:
OK, I see the Lemur Container… but it needs to be a 2D container.

This is how the lemur docs do a simple container:

 Container myWindow = new Container();
        guiNode.attachChild(myWindow);

        // Put it somewhere that we will see it
        // Note: Lemur GUI elements grow down from the upper left corner.
        myWindow.setLocalTranslation(300, 300, 0);

        // Add some elements
        myWindow.addChild(new Label("Hello, World."));
        Button clickMe = myWindow.addChild(new Button("Click Me"));
        clickMe.addClickCommands(new Command<Button>() {
                @Override
                public void execute( Button source ) {
                    System.out.println("The world is yours.");
                }
            });            
    }    

Create the container, add it to the guiNode, and add children to the container. I don’t think it’s where the problem resides.

Ok. I was trying to help until someone else get to it.
(I think I lost ‘helpful’ points on this one! :wink: )

I appreciate it fella. Maybe @pspeed knows something, but I don’t think it is Lemur related. We shall see.

It’s strange to do this in an AppState and not in the application itself. It’s one of the very few things my main application class does. Anyway, it shouldn’t really cause a problem it’s just odd.

I initialize and attach GUIs in my AppState.initialize all the time (though usually it’s a subclass of BaseAppState because I like to avoid all the extra trouble with a plain app state)… so in theory it should work for you too.

Things to double check… at the place you are attaching it, very that the world translation and preferred size have sensible values. Do that after you’ve attached it and you can even verify that something in your code hasn’t moved the guiNode.

If those values look screwy then you can trace back from there.

If they look normal then I’m not sure… it should just work fine.