Is @FXML needed for every declaration or just for the first?
In other words, should I use
@FXML
public Label timerLabel = new Label();
@FXML
public TextField mainTextField, projectTextField ;
@FXML
public Button goButton, deleteAllButton ;
@FXML
public ComboBox<String> projectComboBox ;
@FXML
public TableView<Entry> mainTable ;
@FXML
public TableColumn<Entry, String> titleColumn, timeColumn, dateColumn ;
@FXML
public TableColumn<Entry, Boolean> checkColumn, buttonColumn ;
@FXML
public checkBox checkAllCheckBox ;
Or
@FXML
public Label timerLabel = new Label();
public TextField mainTextField, projectTextField ;
public Button goButton, deleteAllButton ;
public ComboBox<String> projectComboBox ;
public TableView<Entry> mainTable ;
public TableColumn<Entry, String> titleColumn, timeColumn, dateColumn ;
public TableColumn<Entry, Boolean> checkColumn, buttonColumn ;
public checkBox checkAllCheckBox ;
Thank you!
public Label timerLabel = new Label();
annotated by@FXML
is incorrect. The references annotated with@FXML
are initialized at the time of fxml load and should not be initialized externally. – TouchstonetimerLabel = new TimerLabel()
if the timerLabel reference definition was annotated with@FXML
. – Solangesolano@FXML
annotations if your fields arepublic
. Of course, you should never make these fieldspublic
anyway; you should make themprivate
, in which case all the@FXML
annotations are required. But with the code as it is, omitting the annotations will make no difference. – Bowel