Can someone quickly help me? How exactly does the ...
# announcements
l
Can someone quickly help me? How exactly does the code looks for the kotlin class to act as a Controller for a JavaFX scene created by a .fxml file? Because in java you leave the variables undefined which will later be referred to the gui object by the fxml loader, now of course i cant leave the var undefined in kotlin. Java:
Copy code
@FXML
    private ListView<String> entriesList;
    @FXML
    private TextField hostField;
    @FXML
    private TextField nameField;
    @FXML
    private PasswordField passField;
    @FXML
    private TextField pathField;
    @FXML
    private Button testConnBtn;
    @FXML
    private Button saveBtn;
    @FXML
    private Button delBtn;
    @FXML
    private Button saveNewBtn;
    @FXML
    private TextField customPath;
    @FXML
    private ComboBox<String> typeBox;
b
r
You would use `lateinit`:
Copy code
@FXML
private lateinit var entriesList: ListView<String>
@FXML
private lateinit var hostField: TextField
...
But I would also suggest checking out #C136UUPE1
Generally speaking,
lateinit
is the solution to interop with Java dependency injection.
c
But you should prefer constructor injection whenever possible. Not sure if JavaFX supports that though.