title: JavaFX Collision detection between Objects that have different parents
body: <p>I have two panes: paneA and paneB, paneA contains objectA, and paneB contains objectB. However paneA also contains paneB. How can I detect the collision between ObjectA and ObjectB when they have different parents?</p>
  
  <p>I tried the following but it didn't work:</p>
  
  <pre><code>Pane paneA = new Pane();
  Pane paneB = new Pane();
  
  Rectangle objectA = new Rectangle(50,30);
  Rectangle objectB = new Rectangle(80,40);
  
  paneB.getChildren().add(objectB);
  paneA.getChildren().addAll(objectA, paneB);
  
  if(objectA.getBoundsInParent().intersects(objectB.getBoundsInParent()) {
      collision = true;
  }
  </code></pre>