dimanche 24 janvier 2016

Pre-select a JavaFX CheckComboBox

All the solutions I've read relate to ComboBox, not CheckComboBox. Using the ControlsFX CheckComboBox I've been able to add a few options into it using the controller code below. But I can't figure out how to pre-check an option at the time its added to the ArrayList, nor set Prompt Text.

... 
 @FXML
     public CheckComboBox<String> extras;

    @Override
    public void initialize(URL location, ResourceBundle resources) {

        extras.getItems().add("A");
        extras.getItems().add("B");
...

There doesn't seem to be a method like: extras.getItems().add("A", true); or extras.getItems().get(0).setValue(true);

The answer found here uses something like below, but this won't work for CheckComboBox:

extras.setValue(value); and extras.setPromptText("Prompt Text");

Which leaves me asking:

  1. How do I set an option to checked/unchecked during initialization?
  2. How do I set the prompt text on a CheckComboBox?



Aucun commentaire:

Enregistrer un commentaire