I have one JavaFX application window created from one JavaFX tutorial.
I install new windowed content using the following function:
private Initializable replaceSceneContent(final String fxml) throws Exception { // wczytanie fxml FXMLLoader loader = new FXMLLoader(); InputStream in = Main.class.getResourceAsStream(fxml); loader.setBuilderFactory(new JavaFXBuilderFactory()); loader.setLocation(Main.class.getResource(fxml)); AnchorPane page; try { page = (AnchorPane) loader.load(in); } finally { in.close(); } Scene scene = new Scene(page, w, h); stage.setScene(scene); return (Initializable) loader.getController(); }
But I want to select one of the TextFields from this fxml file, which will be active by default. How to do it? I tried calling the requestFocus method in the controller initialization method, but it did not work. I did not find a suitable property in the TextField class or in the AnchorPane class (AnchorPane is the root element of the fxml control tree).
java javafx javafx-2
daprog Nov 12 2018-12-12T00: 00Z
source share