Problem spatial name: Root Node

Im trying to make a little editor where the jme canvas is in a swing frame, but now when I try to add a new Node to the rootNode, this error will sometimes be displayed. looks quite random to me, sometimes it works, sometimes not. all I do is this:



Node node=new Node();

rootNode.attachChild(node);

Give a name to your new node :

[java]Node node=new Node( "myNode" );

rootNode.attachChild(node); [/java]

No, the error says explicitly what you probably do wrong, read the output again.

I dont modify the scene from another thread. I dont know how to fix this.

You say in a swing frame, no? What do you think, on which thread does swing work off its input? Did Oracle/Sun think about jME3 and added automatic thread delegation? I doubt so. Your button presses are worked off on the AWT thread. So… Yes, you do modify from another thread.

oh I forgot about that… although its quite obviously. so how can I solve that? It doesnt crash always but sometimes, I dont know what it depends on.

app.enqueue(), like you have to wrap all calls to swing with java.awt.EventQueue.invokeLater()

Yea when in Swing you always have to remember what thread you are on. We all forget sometimes and then this error pops up.

This tutorial shows how to enqueue tasks in jme, and for swing you will want to use SwingUtils.invokeLater(my callable)

so I should do it like this?



[java]this.enqueue(new Callable<String> ()

{

public String call() throws Exception

{

rootNode.attachChild(new Node());

return null;

}

});[/java]



the String is useless, but I didnt know what else I should insert there.

What type you return is totally out of interest, as long as you dont use the Future.get() method ( What you prohibit to do. I recommend workarounds…)



And yes, whenever you modify your OGL Thread enqueue the task like that.

@maxim said:
so I should do it like this?

[java]this.enqueue(new Callable&lt;String&gt; ()
{
public String call() throws Exception
{
rootNode.attachChild(new Node());
return null;
}
});[/java]

the String is useless, but I didnt know what else I should insert there.

you can return a Void type.