Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The getSelectedProperty <code>Callback</code> parameter of <code>CheckBoxListCell.forListView()</code> is bound bidirectionally,</p> <blockquote> <p>(meaning that the CheckBox in the cell will set/unset this property based on user interactions, and the CheckBox will reflect the state of the ObservableValue, if it changes externally).</p> </blockquote> <p>Thereby adding a change listener to the <code>Card.selectedProperty()</code> may be more accurate, covering the external modification by both checkBoxes and other controls/setters.</p> <pre><code>final IntegerProperty count = new SimpleIntegerProperty(0); Text text = new Text("-"); // Bind count to text, to show on scene. text.textProperty().bind(count.asString()); ChangeListener listener = new ChangeListener&lt;Boolean&gt;() { @Override public void changed(final ObservableValue&lt;? extends Boolean&gt; observable, Boolean oldValue, Boolean newValue) { count.set(count.get() + (newValue ? 1 : -1)); if (count.get() &gt;= 10) { System.out.println("exceeded max limit"); // Revert selection Platform.runLater(new Runnable() { @Override public void run() { ((BooleanProperty) observable).set(false); } }); } } }; for (final Card card : cards.getItems()) { card.selectedProperty().addListener(listener); } </code></pre> <p>At the end of the user work, remove the listeners.</p> <pre><code>for (final Card card : cards.getItems()) { card.selectedProperty().removeListener(listener); } </code></pre> <p>Alternatively, if you strictly want to add listeners to checkboxes only, you can create custom ListCell having checkboxes internally and set a ListView.cellFactory().</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload