Welcome to the CSC Q&A.
Get help and give help!
Write great code!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+33 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 (8 points)

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 (8 points)
+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 (13 points)
...