I am relatively new to JavaFX, so perhaps this is an easy question to answer. I am creating in Java code several (e.g., 5) ChoiceBox instances. I add a handler for when the value of the ChoiceBox changes. My code:
ChoiceBox<String> rpmSelector = new ChoiceBox<>();
ObservableList<String> rpmSelectorItems = FXCollections.observableArrayList();
rpmSelectorItems.add(ALL_RPM);
for (Double engSpeed : engSpeeds) {
rpmSelectorItems.add(String.format("%.0f", engSpeed.doubleValue()));
}
rpmSelector.setItems(rpmSelectorItems);
rpmSelector.getSelectionModel().selectFirst();
rpmSelector.valueProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> obsValue,
String oldValue, String newValue) {
// How can I get the ChoiceBox that was the source of this event?
}
});
My question is: in the "changed" method, how do I determine which of the ChoiceBox instances had its value changed?
Thanks!
Chris
Edited by: 976245 on May 15, 2013 1:05 PM
Edited by: 976245 on May 15, 2013 1:05 PM