Skip to main content

How to change z order of SGNodes?

2 replies [Last post]
mbien
Offline
Joined: 2007-04-29
Points: 0

Hello,

how can I change the z order of a SGNode after it was added to a SGGroup?
In my particular case I want to move the SGNode under the cursor to the top of all other nodes when dragged.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Jim Graham

If you want to move it to the top then you can remove it from the group
and add it again and it will be on top. Since the add method removes a
child from the old group you should be able to just add it again and it
will move it to the top.

For more sophisticate reorderings you would need to use the add method
that takes an index...

...jim

scenario@javadesktop.org wrote:
> Hello,
>
> how can I change the z order of a SGNode after it was added to a SGGroup?
> In my particular case I want to move the SGNode under the mouse to the top of all other nodes when dragged.
> [Message sent by forum member 'mbien' (mbien)]
>
> http://forums.java.net/jive/thread.jspa?messageID=277657
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@scenegraph.dev.java.net
> For additional commands, e-mail: dev-help@scenegraph.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@scenegraph.dev.java.net
For additional commands, e-mail: dev-help@scenegraph.dev.java.net

mbien
Offline
Joined: 2007-04-29
Points: 0

Thanks Jim,

SGParent parent = node.getParent();
parent.remove(node);
((SGGroup)parent).add(node);

thats actually how I have implemented it, but it feels like a workaround... I hoped there would be a cleaner solution for a scenegraph to change paint order of nodes. SGGroup is probably the best place for this kind of node reordering functionality.

Also SGParent has a remove method but no add method is this intended?