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

JavaFX module javafx.graphics

The root cause for the issue is contained in this line: Caused by: java.lang.IllegalAccessException: class com.sun.javafx.application.LauncherImpl (in module javafx.graphics) cannot access class reports.Main (in module Reports) because module Reports does not export reports to module javafx.graphics Application.launch uses reflection to create a instance of the application class using reflection. External classes like Application are only … Read more

JavaFX – create custom button with image

There are a few different ways to accomplish this, I’ll outline my favourites. Use a ToggleButton and apply a custom style to it. I suggest this because your required control is “like a toggle button” but just looks different from the default toggle button styling. My preferred method is to define a graphic for the … Read more

Customize ListView in JavaFX with FXML

I understand your question. There are mainly two ways to set items in a Listview: 1. Create the ObservableList and set the items of the ListView with the ObservableList (listView.setItems(observableList)). 2. Use the setCellFactory() method of the ListView class. You would prefer to use the setCellFactory() method, because this approach simplies the process as well … Read more