1

I am converting an existing swing app to JavaFX. I would think that this code would return a node called "#paneRightBottom", but it returns null. Using the netbeans debugger I am able to drill down on the "topNode" and find the "#paneRightBottom" node six levels deep, so it is there. I have read the online docs and think that I should be getting a node. Does anyone have an idea of where I've gone wrong?

        Node topNode = FXMLLoader.load(AFI.class.getResource("afimain.fxml"));
        System.out.println(topNode.getId());
        Node node = topNode.lookup("#paneRightBottom");
Bob Smith
  • 13
  • 1
  • 5

1 Answers1

3

Check if the node, which you are trying to lookup, has an id="paneRightBottom" and not fx:id="paneRightBottom". If it has then give more details by posting your fxml file too.

Uluk Biy
  • 48,655
  • 13
  • 146
  • 153
  • Thanks @Uluk, I had already marked up the xml to account for the different id formats. I'm still looking at it but I believe that it has to do with split panes not considering the panes to be children but rather items. This makes writing a traversing method a bit less elegant, having to use instanceof to check for split panes seems wrong somehow. I didn't consider split panes as a problem so didn't – Bob Smith Dec 29 '12 at 04:38
  • @BobSmith. If you didn't look at yet, see [JavaFX 2.0 + FXML - strange lookup behaviour](http://stackoverflow.com/q/12324799/682495). I think the answer can be applied to your use case as well. – Uluk Biy Dec 29 '12 at 09:57