package tests; import javafx.application.Application; import javafx.event.Event; import javafx.event.EventHandler; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.ListView; import javafx.scene.control.ScrollPane; import javafx.scene.control.SplitPane; import javafx.scene.control.TreeView; import javafx.scene.input.MouseEvent; import javafx.scene.layout.AnchorPane; import javafx.stage.Stage; public class FocusTest1 extends Application { public static void main(String[] args) { Application.launch(FocusTest1.class, null); } public void start(Stage stage) { final Scene scene = new Scene(new Group()); stage.setTitle("TEST"); stage.setWidth(600); stage.setHeight(600); stage.setScene(scene); stage.show(); final ScrollPane scrollPane = new ScrollPane(); scrollPane.setStyle("-fx-background-color: yellow;"); scrollPane.setOnMouseClicked(new EventHandler() { public void handle(MouseEvent event) { System.out.println("================"); System.out.println("== Click on " + scrollPane); System.out.println("== FocusOwner is " + scene.getImpl_focusOwner()); } }); final TreeView treeView = new TreeView(); treeView.setStyle("-fx-background-color: green;"); treeView.setOnMouseClicked(new EventHandler() { public void handle(MouseEvent event) { System.out.println("================"); System.out.println("== Click on " + treeView); System.out.println("== FocusOwner is " + scene.getImpl_focusOwner()); } }); final AnchorPane anchorPane = new AnchorPane(); anchorPane.setStyle("-fx-background-color: blue;"); anchorPane.setOnMouseClicked(new EventHandler() { public void handle(MouseEvent event) { System.out.println("================"); System.out.println("== Click on " + anchorPane); System.out.println("== FocusOwner is " + scene.getImpl_focusOwner()); } }); final SplitPane splitPane = new SplitPane(); splitPane.setLayoutX(10); splitPane.setLayoutY(10); splitPane.setMaxSize(200, 200); splitPane.setDividerPositions(0.2, 0.4, 0.6); // splitPane.getItems().addAll(scrollPane, anchorPane, treeView); splitPane.getItems().addAll(scrollPane, anchorPane); ((Group) scene.getRoot()).getChildren().addAll(splitPane); } }