title: Disable some context menu Items if multiple rows selected in TableView JavaFx
body: <p>I'm new to JavaFx. Is there a way that I can bind an menu item's <code>disable property</code> to a <code>tableview</code>'s selection property. So menu item get disable if multiple rows are selected?</p>
  
  <p>I tried </p>
  
  <pre><code>mnuItem.disableProperty().bind(tblView.selectionModelProperty().isNull());
  </code></pre>
  
  <p>But it get disable for both single and multiple selections.</p>
  
  <p>How can I disable a menu item in multiple rows are selected in table view ?</p>
  
  <p><strong>P.S.</strong> I know and tried to do that with a listener like below</p>
  
  <pre><code> tblView.getSelectionModel().getSelectedIndices().addListener(new ListChangeListener&lt;Integer&gt;() {
         @Override
         public void onChanged(Change&lt;? extends Integer&gt; change) {
              if (change.getList().size() &gt;= 2) {
                   mnuItem.setDisable(true);
              } else {
                   mnuItem.setDisable(false);
              }
         }
   });
  </code></pre>
  
  <p>but, it throws an exception <em>"java.lang.RuntimeException : A bound value cannot be set"</em></p>
  
  <pre><code>Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: A bound value cannot be set.
  at javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:139)
  at javafx.scene.control.MenuItem.setDisable(MenuItem.java:380)
  at myPkg.MyController$14.onChanged(MyController.java:393)
  </code></pre>