I have an element with the ID history
type of TableView
. How can I find and access this object if I have the instance of Scene scene
?
Asked
Active
Viewed 7.5k times
1 Answers
142
Try
TableView tb = (TableView) scene.lookup("#history");

Uluk Biy
- 48,655
- 13
- 146
- 153
-
5A pound sign is required when looking up an id. So it should look like this: scene.lookup("#history"); – Orbiting Eden Jun 11 '13 at 21:52
-
2@Uluk Biy can you update your answer with as TableView tb = (TableView) scene.lookup("#history"); so that others will easily understand by seeing the answer. Thank you. – AJJ Oct 30 '13 at 10:44
-
9There is one important thing. This will work **after** you will invoke ```primaryStage.show()``` – MAGx2 May 30 '17 at 10:33
-
1@MAGx2 _This will work after you will invoke primaryStage.show()_ as a general statement, that's not quite right (depends on how the nodes are injected - see https://stackoverflow.com/questions/68475291/javafx-finding-node-by-id) – kleopatra Jul 22 '21 at 10:20