Nodes outside simpleApplicaiton / AppState

I have a class that handles loading objects that exist outside simpleApplication and AppState. The class creates a node. I noticed when I load anything into the node it’s automatically loaded into the main game loop. I was curious if I could access the rootNode / guiNode outside of appstate/simpleApplication ? If not then is there any draw back to making a node outside those two classes other than the fact the node only exist as long as the class is in memory ?

Of course. Just pass it where it’s needed.

JME is really going to be a hard thing to learn without a decent Java foundation.

When I pass the guiNode from simpleApplication to the new class upon creation it ignore

public class SimpleInterface {

private Node guiNode;

 public SimpleInterface(Node guiNode){

       this.guiNode =;


This creates an independent node only specific to my class and doesn’t reference the guiNode.

That code is very confused. You pass a value and then never use it… instead you are grabbing the node from some magic ‘app’ variable. As written, this code won’t even compile.

Please don’t bother to waste our time hand-typing fake code here. Show us the actual code or don’t bother, really.

1 Like

Disregard I just realized the guiNode was declared but wasn’t passed in the constructor and was accessing a phantom node. What is odd is the phantom node was existing in memory until I closed the app or tried to access the guiNode then realizing it was null. This is what happens when your files start to go into thousands of lines.

Well, the code you posted was basically nonsense… so it’s hard for us to help, anyway. It’s a sign that you are still just beginning with Java and just trying random things in hopes one will hit.

We all have to start there but you’ve kind of picked one of the hardest ways to go about it.

Learning to shave with a straight razor is tricky. Learning to ride bike is also tricky. Trying to do them both at once… can lead to bad places. :slight_smile:

1 Like

I’m not new to Java. I’ve been programming for 15+ years now. Only two of those years has been with Java but I know my way around the programming world. What happened is I made an empty AppState class I was using as a base for all of my AppStates. In the empty class I made a bunch of variables for Appsettings, statemanager , rootnode , guinode etc.

I passed everything into the constructor but overlooked the guiNode. My class had this guiNode that was initialized as only an instance variable for that class with no references to the main class guiNode. When I created a new appState instance and passed the guiNode to the SimpleInterface class I was passing a freshly created node with no references to my scene. Which explains all of the crashes on exit.

Lesson of the day. Verify and verify again.

Sorry if I jumped to conclusions. Please understand how it looked from our end where even the sample code was obviously wrong.