Hi!
I have a FXML-file with a group of many similar elements (e.g. checkboxes). Those elements use the same CSS-Styles, therefore they all have to have the same ID-value (e.g. "checkboxCSS") , but different and unique FX:ID values (e.g. "checkboxFXID_1" ... "checkboxFXID_999"). All those checkbox are connected to the same method (#someAction) in the controller class.
<Checkbox onAction="#someAction" id="checkboxCSS" fx:id="checkboxFX1" text="1" />
<Checkbox onAction="#someAction" id="checkboxCSS" fx:id="checkboxFX2" text="2" />
...
<Checkbox onAction="#someAction" id="checkboxCSS" fx:id="checkboxFX999" text="999" />
Inside the controller class, I would like to determine the event.source (FX:ID), so I can know which checkbox has been clicked by the user. But it seems, I can only get the type and the ID-value, but not the fx:id value.
Here is what I tried to use...
@FXML private void someAction(ActionEvent event) { System.out.println(event.getSource()); }
And the corresponding output...
CheckBox[id=checkboxCSS, styleClass=check-box]
Best regards,
J. Ishikawa