Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+34 votes

Does anyone know how to access the index of the choice that we made from the ComboBox in JavaFX?

asked in CSC285_Fall2018 by (1 point)

2 Answers

+18 votes

Well if you use a ChoiceBox instead of a ComboBox, you can access the choice by using the getValue() method in the ChoiceBox. We used that to get the id of the chick and then access the AnimalTrack by the id.

answered by (1 point)
+3

Thanks a lot. This should be helpful for our project

+15 votes

I believe you can do comboBox.getSelectionModel().getSelectedIndex() -- this is off the top of my head though, so you may want to check online for examples.

answered by (3.5k points)
...