3

I have a ChoiceBox that I want to set with an ObservableList. In JavaFX I might do:

ObservableList genres = FXCollections.observableArrayList(
  "Chamber",
  "Country",
  "Cowbell",
  "Metal",
  "Polka",
  "Rock"
);

choiceBox.setItems(genres);

But I can't find any equivalent examples in ScalaFX. What would that look like?

user79074
  • 4,937
  • 5
  • 29
  • 57

1 Answers1

0

ScalaFX prides wrappers for JavaFX collections that are compatible with Scala collections. You can do following:

  var genres = ObservableBuffer(
    "Chamber",
    "Country",
    "Cowbell",
    "Metal",
    "Polka",
    "Rock"
  )

  choiceBox.items = genres

You will find more example in ProScalaFX project: https://github.com/scalafx/ProScalaFX

Jarek
  • 1,513
  • 9
  • 16