FXMLLoader getController returns NULL?

Change this @FXML public void editPerson() { try { FXMLLoader loader = new FXMLLoader(getClass().getResource( “PersonEditor.fxml”)); PersonEditorCtrl ctrl = loader.getController(); ctrl.init(table.getSelectionModel().getSelectedItem()); Parent root = (Parent) loader.load(); Scene newScene = new Scene(root); Stage newStage = new Stage(); newStage.setScene(newScene); newStage.show(); } catch (Exception e) { e.printStackTrace(); } } To that: @FXML public void editPerson() { try { FXMLLoader … Read more

Can not work with MediaPlayer class, javafx.media is not found

Note: This answer applies to other JavaFX modules such as fxml and web, as well. javafx.media is a module, you need to require it in your module-info.java like you do for javafx.controls and javafx.fxml. module org.project { requires javafx.controls; requires javafx.fxml; requires javafx.media; opens org.project to javafx.fxml; exports org.project; } There may be other issues, … Read more

Border-Radius and Shadow on ImageView

Use the following css to get a drop shadow: -fx-effect: dropshadow(three-pass-box, rgba(0,0,0,0.8), 10, 0, 0, 0); See the JavaFX CSS Reference guide for details. To get the border in addition to the drop shadow, place your ImageView containing your Image in a StackPane. And apply the effect css above to the StackPane, in addition to … Read more

JavaFX8 fxml naming of nested controllers

Yes the field name the controller is injected to is always constructed by concatenating the fx:id of the <fx:include> tag with “Controller”. It’s “hidden” in the documentation of the FXMLLoader.CONTROLLER_SUFFIX field. A suffix for controllers of included fxml files. The full key is stored in namespace map. (The namespace map contains all the objects by … Read more

JavaFX ComboBox change value causes IndexOutOfBoundsException

In JavaFX, you cannot change the contents of an ObservableList while a change is already in progress. What is happening here is that your listeners (any of the ones you try) are being fired as part of the box.getSelctionModel().getSelectedItems() ObservableList changing. So basically, you cannot change the selection while a selection change is being processed. … Read more