Java Magazine, September/October 2017
ORACLE COM JAVAMAGAZINE SEPTEMBER OCTOBER 2017 59 javafx import javafx event ActionEvent import javafx fxml FXML import javafx scene control ListView import javax inject Inject public class AppController @ FXML private ListView String theList private final DataProvider String dataProvider @ Inject public AppController DataProvider String dp this dataProvider dp public void initialize theList getItems addAll dataProvider getData public void addItem ActionEvent ignored theList getItems add Item theList getItems size Notice that the controller defines a constructor with a single argument and is also annotated with @ Inject This simple change contradicts the FXMLLoader conventions for instantiating a controller You must find another way to let FXMLLoader work with the controller class Luckily there is such a way FXMLLoader can be configured to use a diferent strategy to instantiate the
You must have JavaScript enabled to view digital editions.