JavaFX Controls in Default Window

Given you’ve already imported class Canvas, you can shorten your (cast):
canvas = (Canvas)surface.getNative();

Same for pane = (javafx.scene.layout.Pane)canvas.getParent();:
pane = (Pane)canvas.getParent();

1 Like