Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaFX: Bound value cannot be set exception

In my javafx application I have created a table view where I have some projects. If the projects are there in the table view, then the delete button should be enabled, otherwise delete button should be disabled.

Now the problem is that when I select the project and click the delete button it's throwing the following exception.

How can I solve this?

This is my tableview code.

tableViewProject.setOnMouseClicked(new EventHandler<MouseEvent>() {
    @Override
    public void handle(MouseEvent event) {
        Project selectedProject = tableViewProject.getSelectionModel().getSelectedItem();
        if (selectedProject != null) {
            currentProject = selectedProject;
            propertyChangeSupport.firePropertyChange("projectManagerController.projectIsSelected", null, selectedProject);
            btn_remove_project.setDisable(false);
        } else {
            btn_remove_project.setDisable(true);
        }
    }
});
Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: Button.disable : A bound value cannot be set.
at javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:140)
at javafx.scene.Node.setDisable(Node.java:1543)
at com.virtusa.tempo.server.ui.controllers.ProjectManagerController$3.handle(ProjectManagerController.java:131)
at com.virtusa.tempo.server.ui.controllers.ProjectManagerController$3.handle(ProjectManagerController.java:124)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Scene$ClickGenerator.postProcess(Scene.java:3471)
at javafx.scene.Scene$ClickGenerator.access$8100(Scene.java:3399)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3767)
at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3486)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2495)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:350)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:275)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$350(GlassViewEventHandler.java:385)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$$Lambda$355/919089086.get(Unknown Source)
at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:404)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:384)
at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
at com.sun.glass.ui.View.notifyMouse(View.java:927)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$145(WinApplication.java:101)
at com.sun.glass.ui.win.WinApplication$$Lambda$39/1633781598.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
like image 410
qwerty Avatar asked Nov 03 '15 10:11

qwerty


2 Answers

I have this problem in a JavaFX ImageView when it bind to a property:

imageViewProfile.imageProperty().bind(imageProperty);

to unbind and fix this error "JavaFX: Bound value cannot be set exception ", I have to unbind with:

imageViewProfile.imageProperty().unbind();
like image 139
NELSON RODRIGUEZ Avatar answered Oct 24 '22 05:10

NELSON RODRIGUEZ


You are probably binding it to a property somewhere. This is a one way binding. In order to send information back from the control you need to change it to bindBidirectional

like image 16
Erik Englund Avatar answered Oct 24 '22 06:10

Erik Englund