jMonkeyEngine-Contributions / Lemur

Lemur is a jMonkeyEngine-based UI toolkit.
http://jmonkeyengine-contributions.github.io/Lemur/
BSD 3-Clause "New" or "Revised" License
116 stars 33 forks source link

How to update labels in jME from outside of SimpleApplication. #110

Closed erikmartinessanches closed 2 years ago

erikmartinessanches commented 2 years ago

I've followed the Lemur Getting started example and now have a situation similar to the "full source example" at the bottom of the page in the above link.

In jME's simpleInitApp() I create the GUI:

        GuiGlobals.initialize(this);
        BaseStyles.loadGlassStyle();
        GuiGlobals.getInstance().getStyles().setDefaultStyle("glass");
        Container myUiElements = new Container();
        myUiElements.setName("myUiElements");
        guiNode.attachChild(myUiElements);
        myUiElements.setLocalTranslation(0, 480, 0);
        Label myLabel = new Label("Initial label text");
        myLabel.setName("myLabel");
        myUiElements.addChild(myLabel);

Then, from my own networking code, which is outside of the class that extends jME's SimpleApplication, I would like to modify the label's text.

I tried

        final Node tempNode = (Node) clientWindow.getGuiNode().getChild("myUiElements");
        final Label tempLabel = tempNode.getChild("myLabel"); //This does not give me access to Label's .setText() method.

And, do I also have to "enqueue" it?

pspeed42 commented 2 years ago

Answered on the JME forum.