Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How do I listen for change in the global position of a Node

alabala_kirilSep 8 2011 — edited Sep 28 2011
Hi there,

I want to create a Wire/Connection node between two scene nodes. I want this Wire node to be updated when one of the nodes is moving. In the common scenario I would listen for change events in the target nodes position and update the Wire :

targetNode1.translateXProperty().addListener(new ChangeListener<Number>() {
public void changed(ObservableValue value, Number oldValue, Number newValue) {
wire.setStartX(targetNode1.getTranslateX());
wire.setStartX(targetNode1.getTranslateY());

wire.setEndX(targetNode2.getTranslateX());
wire.setEndY(targetNode2.getTranslateY());
}
});



The problem is that the target nodes are children of another container nodes(that are actually moving). So listening for change events in the translate properties of the target nodes does not work(their parent nodes are actually moving)

Is there way to listent for change in the global position of the target nodes relative to the Scene?
This post has been answered by Richard Bair-Oracle on Sep 20 2011
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 26 2011
Added on Sep 8 2011
8 comments
596 views