You can make any transparent "transparent" panel so that it does not consume any click events and does not pass them onto the stack under it.
Here is an example code ... this example sets 4 stacks on the stack, and it just starts from the moment you press the mainPane button.
StackPane rootPane = new StackPane(); VBox mainPane = new VBox(80); BorderPane helpOverlayPane = new BorderPane(); helpOverlayPane.setMouseTransparent(true); Canvas fullScreenOverlayCanvas = new Canvas(); fullScreenOverlayCanvas.setMouseTransparent(true); VBox debugPane = new VBox(); debugPane.setAlignment(Pos.BASELINE_RIGHT); AnchorPane debugOverlay = new AnchorPane(); debugOverlay.setMouseTransparent(true); debugOverlay.getChildren().add(debugPane); AnchorPane.setBottomAnchor(debugPane, 80.0); AnchorPane.setRightAnchor(debugPane, 20.0); rootPane.getChildren().addAll(mainPane, fullScreenOverlayCanvas, debugOverlay, helpOverlayPane);
Now that you want to use your canvas to paint on top, make sure that you change the mouse transparency to false only for this stack and keep all the panels on top of the transparent mouse.
fullScreenOverlayCanvas.setMouseTransparent(false); debugOverlay.setMouseTransparent(true); fullScreenOverlayCanvas.setVisible(true); doSomethingWithCanvasThatNeedsMouseClicks();
PS I did some editing of the code that I had, so it may not work as it is. Also, see the discussion on how to make only parts of panels transparent: JavaFX Pass MouseEvents through a transparent Node for children
source share