Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8125999

CheckBoxTreeItem: RTE on attempt to set binded "selected" property

XMLWordPrintable

      RTE on attempt to set binded "selected" property if "independent" property is set to false

      Sample to reproduce:

      import javafx.application.Application;
      import javafx.beans.value.ChangeListener;
      import javafx.beans.value.ObservableValue;
      import javafx.scene.Scene;
      import javafx.scene.control.CheckBox;
      import javafx.scene.control.CheckBoxTreeItem;
      import javafx.scene.control.TreeView;
      import javafx.scene.control.cell.CheckBoxTreeCell;
      import javafx.scene.layout.HBox;
      import javafx.stage.Stage;

      public class Main extends Application {

          final TreeView tree_view = new TreeView();

          public static void main(String[] args) {
                  Application.launch(args);
          }

          @Override
          public void start(final Stage stage) throws Exception {
              final HBox root = new HBox();
              final Scene scene = new Scene(root, 400, 400);

              tree_view.setEditable(true);

              tree_view.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<CheckBoxTreeItem>() {
                  public void changed(ObservableValue<? extends CheckBoxTreeItem> ov, CheckBoxTreeItem t, CheckBoxTreeItem new_item) {
                  }
              });

              tree_view.setCellFactory(CheckBoxTreeCell.<String>forTreeView());

              root.getChildren().add(tree_view);

              CheckBoxTreeItem<String> tree_root = new CheckBoxTreeItem<String>("Root");

              tree_root.setExpanded(true);

              addLevel(tree_root, 3);

              tree_view.setRoot(tree_root);
              tree_view.setShowRoot(true);

              CheckBox check = new CheckBox();
              tree_root.selectedProperty().bind(check.selectedProperty());

              root.getChildren().add(check);

              stage.setScene(scene);
              stage.show();
          }

          protected void addLevel(CheckBoxTreeItem<String> parent, int level) {
              if (level == 0) {
                  return;
              }
              for (int i = 0; i < 3; i++) {
                  final CheckBoxTreeItem<String> checkBoxTreeItem = new CheckBoxTreeItem<String>("DataItem " + i);
                  parent.getChildren().add(checkBoxTreeItem);
                  addLevel(checkBoxTreeItem, level - 1);
              }
          }

      }

      java.lang.RuntimeException: A bound value cannot be set.
              at javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:157)
              at javafx.beans.property.BooleanProperty.setValue(BooleanProperty.java:81)
              at javafx.scene.control.CheckBoxTreeItem.setSelected(CheckBoxTreeItem.java:192)
              at javafx.scene.control.CheckBoxTreeItem.updateUpwards(CheckBoxTreeItem.java:273)
              at javafx.scene.control.CheckBoxTreeItem.updateState(CheckBoxTreeItem.java:248)
              at javafx.scene.control.CheckBoxTreeItem.access$000(CheckBoxTreeItem.java:78)
              at javafx.scene.control.CheckBoxTreeItem$1.changed(CheckBoxTreeItem.java:173)
              at javafx.scene.control.CheckBoxTreeItem$1.changed(CheckBoxTreeItem.java:171)
              at com.sun.javafx.binding.ExpressionHelper$Generic.fireValueChangedEvent(ExpressionHelper.java:367)
              at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:100)
              at javafx.beans.property.BooleanPropertyBase.fireValueChangedEvent(BooleanPropertyBase.java:121)
              at javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:128)
              at javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:161)
              at javafx.beans.property.BooleanProperty.setValue(BooleanProperty.java:81)
              at javafx.scene.control.CheckBoxTreeItem.setSelected(CheckBoxTreeItem.java:192)
              at javafx.scene.control.CheckBoxTreeItem.updateDownwards(CheckBoxTreeItem.java:290)
              at javafx.scene.control.CheckBoxTreeItem.updateState(CheckBoxTreeItem.java:254)
              at javafx.scene.control.CheckBoxTreeItem.access$000(CheckBoxTreeItem.java:78)
              at javafx.scene.control.CheckBoxTreeItem$1.changed(CheckBoxTreeItem.java:173)
              at javafx.scene.control.CheckBoxTreeItem$1.changed(CheckBoxTreeItem.java:171)
              at com.sun.javafx.binding.ExpressionHelper$Generic.fireValueChangedEvent(ExpressionHelper.java:367)
              at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:100)
              at javafx.beans.property.BooleanPropertyBase.fireValueChangedEvent(BooleanPropertyBase.java:121)
              at javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:128)
              at javafx.beans.property.BooleanPropertyBase.access$100(BooleanPropertyBase.java:67)
              at javafx.beans.property.BooleanPropertyBase$Listener.invalidated(BooleanPropertyBase.java:249)
              at com.sun.javafx.binding.ExpressionHelper$SingleInvalidation.fireValueChangedEvent(ExpressionHelper.java:155)
              at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:100)
              at javafx.beans.property.BooleanPropertyBase.fireValueChangedEvent(BooleanPropertyBase.java:121)
              at javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:128)
              at javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:161)
              at javafx.scene.control.CheckBox.setSelected(CheckBox.java:147)
              at javafx.scene.control.CheckBox.fire(CheckBox.java:225)
              at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:193)
              at com.sun.javafx.scene.control.skin.SkinBase$4.handle(SkinBase.java:336)
              at com.sun.javafx.scene.control.skin.SkinBase$4.handle(SkinBase.java:329)
              at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:64)
              at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:217)
              at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:170)
              at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:38)
              at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:37)
              at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
              at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
              at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
              at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
              at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
              at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:53)
              at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:33)
              at javafx.event.Event.fireEvent(Event.java:171)
              at javafx.scene.Scene$MouseHandler.process(Scene.java:3319)
              at javafx.scene.Scene$MouseHandler.process(Scene.java:3159)
              at javafx.scene.Scene$MouseHandler.access$1900(Scene.java:3114)
              at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1536)
              at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2256)
              at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:227)
              at com.sun.glass.ui.View.handleMouseEvent(View.java:528)
              at com.sun.glass.ui.View.notifyMouse(View.java:921)
              at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
              at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
              at com.sun.glass.ui.win.WinApplication$2$1.run(WinApplication.java:62)
              at java.lang.Thread.run(Thread.java:662)
      Exception in thread "JavaFX Application Thread"

            jgiles Jonathan Giles
            ogb Oleg Barbashov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: