Node lookup with TabPane

Christian krampenschiesser at gmail.com
Sun Jun 8 08:31:37 UTC 2014


Hi,
I'm not sure if this is a bug because it looks like it is designed this way.
I just tried to do a TabPane.lookupAll("#myId") which does not return 
any result.
This is because the TabPane doesn't add the Tabs(which are no nodes) to 
its children.
If it would add the content of each pane to the children the lookup 
would work.
My solution right now is to scan the scenegraph myself.
It is just not that easy to determine when to use lookupAll and when to 
manually scan the scenegraph.
Didn't yet check it but I think the same might apply to containers like 
Accordion.
Would be nice if somebody could give me some clarification.
Thanks,
Christian


Unit Test:
public class TabTest {
   @Test
   public void testLookup() throws Exception {
     TabPane tabPane = new TabPane();
     Tab tab1 = new Tab("tab1");
     tabPane.getTabs().add(tab1);

     StackPane content = new StackPane();
     TextField nodeWithId = new TextField();
     nodeWithId.setId("test");
     content.getChildren().add(nodeWithId);
     tab1.setContent(content);

     assertSame(nodeWithId, content.lookup("#test"));
     Set<Node> idNodes = tabPane.lookupAll("#test");
     assertEquals(1,idNodes.size());
     assertSame(nodeWithId, tabPane.lookup("#test"));
   }
}


More information about the openjfx-dev mailing list