Skip to content

Instantly share code, notes, and snippets.

@phdoerfler
Created March 21, 2013 11:21
Show Gist options
  • Save phdoerfler/5212324 to your computer and use it in GitHub Desktop.
Save phdoerfler/5212324 to your computer and use it in GitHub Desktop.
lookup with attached Scene and parent
package bugs;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.ScrollPaneBuilder;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.AnchorPaneBuilder;
import javafx.scene.layout.StackPaneBuilder;
import javafx.stage.Stage;
public class LookupShowJava extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) throws Exception {
AnchorPane p = AnchorPaneBuilder.create()
.children(
ScrollPaneBuilder.create()
.id("foo")
.content(
StackPaneBuilder.create()
.id("bar")
.build())
.build())
.build();
stage.setScene(new Scene(p));
//stage.show();
System.out.println(p.lookup("#foo")); // Prints: ScrollPane[id=foo, styleClass=scroll-pane]
System.out.println(p.lookup("#foo").lookup("#bar")); // Prints: null
}
}
@phdoerfler
Copy link
Author

Uncomment line 30 and the second println will print: StackPane[id=bar]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment