AssignToBoundException

It's probably me not getting all the subtilities of data binding, but isn't the example underneath supposed to work without errors ?
Enter some text in the first text field and navigate to the second. The exception is thrown when the focus leaves the first text field.
Btw, changing the variable "entry" into a "def" yields the same error.
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.TextBox;
import javafx.scene.layout.VBox;
class StackEntry {
    var title:String;
    var notes:String;
var entry = StackEntry{};
Stage {
    title: "Binding Test"
    width: 250
    height: 100
    scene: Scene {
        content: [
            VBox {
                spacing: 5
                content: [
                        TextBox {
                            text: bind entry.title
                        TextBox {
                            text: bind entry.notes
}Edited by: Java.Artisan on Jun 24, 2009 4:17 AM

This makes it a somewhat "less boilerplaty". If someone knows a shortcut...
import javafx.scene.control.TextBox;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.KeyCode;
public class ATextBox extends TextBox {
    var originalKeyReleased:function( event:KeyEvent );
    public-init var onChange:function( value:String );
    // the value should be send when the control loses focus
    override public-read var focused on replace {
        // if the control loses focus => send the value
        if ( not focused ) {
            if ( onChange != null ) {
                onChange( text );
    postinit {
        // keep a reference to the original key listener
        originalKeyReleased = this.onKeyReleased;
        // put our implementation in place
        this.onKeyReleased = interceptKey;
    function interceptKey( event:KeyEvent ) {
        if ( onChange != null ) {
            // if the user pressed enter or tab => send the value
            if ( event.code == KeyCode.VK_TAB or event.code == KeyCode.VK_ENTER )
                onChange( text );
        // execute the original listener - if precified
        if ( originalKeyReleased != null ) {
            originalKeyReleased( event );
}

Similar Messages

  • Netbeans 6.9 beta

    Hi,
    I just installed the netbeans 6.9 beta on my MAC and importing my existing 6.8 workspace. First start up gave an exception (some state exception) but the second time it went OK.
    After the class searches in my existing javaFX project:
    1. I got some errors which are not given in the 6.8.
    2. When I take a look in the plugin section I still see it's javaFx 1.2.1
    The first point are errors on sun package imports:
    import com.sun.javafx.scene.control.caspian.TextBoxSkin;
    import com.sun.javafx.scene.control.caspian.ButtonSkin;
    -> they don't existFor the second point I assumed when installing 6.9 automatically javaFX 1.3 was taken as a plugin but this is not the case. Maybe this must be upgraded manually I don't know.
    Anyone did see those errors too ?
    Thanks
    Guy

    hi phil,
    Yes they gave us plenty of work with this update for sure.
    In my case it's even worse I get a runtime error that I don't have with previous version:
    Unexpected exception caught in MasterTimer.timePulse():
    com.sun.javafx.runtime.AssignToBoundException: Cannot assign to bound variableI'm not going into detail on my code ( it's bind on a tile customnode ) but if I run my same source files (ca 10 FX files in my project) build with netbeans 6.8 and javaFx 1.2 they seems to run perfectly.
    I use quit some binding in my program so I guess they changed a lot in that area too.
    I really don't know if it's a good thing to continue putting further time and effort in this language if I must be honest here. Great promises at Devoxx end 2008 here in Antwerp and now almost 2 years later we get something like that ?
    I'd expect a nice update on performance , controls ,... To give just a small example I used some edit boxes and as you know they were very primitive when it came to layout and alignment. Now I checked if they added some alignment into that control but nope they didn't. It seems to be they did for button text tough.
    Also releasing mobile 1.3 at the same time was a must have in my opinion because I can write some 1000 lines on that if I want ;-)
    I wrote a comment once on a blog of Michael Heinrichs which is in the mobile team I think:
    http://blog.netopyr.com/2009/02/22/best-practices-for-javafx-mobile-applications/
    -> the last comment is mine ;-)
    The 1 miljon question I have is:
    Is HTML5 the future candidate to build nice rich interfaces and replace most of the kind of things like javaFx , Flash , Silverlight ?
    ( Don't give your bankaccount ;-)
    -G

  • Binding in one place, setting from another - problems

    First my apologies - I thought this was answered here:
    [http://forums.sun.com/thread.jspa?forumID=974&threadID=5429106]
    Now that I am actually getting around to trying it, still have issues.
    The problem: Need to have a custom node respond to hover, and be able to trigger that behavior from outside the node via code.
    The solution I tried:
    (from the Custom Node)
    var rectStrokeColor: javafx.scene.paint.Color;
    public var isRectHovered: Boolean = bind rect.hover  on replace {
    if(isRectHovered) {
      rectStrokeColor = Color.RED;
    }else{
      rectStrokeColor = Color.LIGHTGRAY;
    override function create(): Node {
            Group {
                content: [
                    rect = Rectangle {
                        width: 180, height: 90
                        stroke: bind rectStrokeColorSo far so good. It works. Untill I do this from outside the node:
        node.isRectHovered = true;As soon as I run the last, I get:
    Exception in thread "AWT-EventQueue-0" com.sun.javafx.runtime.AssignToBoundException: Cannot assign to bound variableSorry - I did think this was solved earlier - guess I didn't test it completely. Any ideas on a fix come to mind?
    Thank you

    Exception in thread "AWT-EventQueue-0" com.sun.javafx.runtime.AssignToBoundException: Cannot assign to bound variableWell, seeing the message, I see two solutions: either don't assign to this variable, or don't bound it... :-)
    I made a little experiment, where I do none (I don't assign it, not from outside at least, I don't bind it):
    class CardFX extends CustomNode
        var rectStrokeColor: Color;
        var rect: Rectangle;
        override var hover on replace
            showHovered(hover);
        public function showHovered(hover: Boolean): Void
            if (hover)
                rectStrokeColor = Color.RED;
            else
                rectStrokeColor = Color.LIGHTGRAY;
        override protected function create(): Node
            Group
                content:
                    rect = Rectangle
                        width: 180, height: 90
                        stroke: bind rectStrokeColor
                        fill: Color.IVORY
    def node = CardFX { translateX: 50, translateY: 100 }
    var scene: Scene;
    Stage
        title: "Forum Test"
        scene: scene = Scene
            width: 500
            height: 500
            fill: Color.ORANGE
            content:
                Button
                    text: "Click me"
                    action: function (): Void { node.showHovered(true); }
                node
    }

  • Clipping of SwingLabel

    Hi,
    does anyone know how to clip SwingLabel or controls in general? I'd like to create a component that displays HTML formatted text. I've got a rectangle that should contain SwingLabel and this SwingLabel has a ScrollBar attached to it. So far, I have problem with clipping of text - it exceeds size of the rectangle. The only way how to avoid it now is to have same color of text and background (scene, stage, node).

    Okay, here's what I've got so far. I got the clipping correctly, but there's a bug because I'm getting
    Exception in trigger:
    com.sun.javafx.runtime.AssignToBoundException: Cannot assign to bound variable
    after I resize the rectangle and then try to scroll down the content. Any help with this will be appreciated :)
    import javafx.stage.Stage;
    import javafx.scene.Scene;
    import javafx.ext.swing.SwingLabel;
    import javafx.scene.control.ScrollBar;
    import javafx.scene.layout.ClipView;
    import javafx.scene.input.MouseEvent;
    import javafx.scene.shape.Rectangle;
    import javafx.scene.paint.Color;
    import javafx.scene.text.Font;
    * @author jiri
    var nodeW: Number = 320; var nodeH: Number = 180;
    var nodeX: Number = 0; var nodeY: Number = 0;
    var contentFont: Font = Font {
        size: 12
    var content: SwingLabel = SwingLabel {
        width: bind nodeW - 17, height: 700
        translateX: 5
        foreground: Color.WHITE
        font: contentFont
        text: "<html><head></head><body>"
              "<h2>Bend your Pixels with Flex 4</h2>"
              "<p align=\"justify\">Flex filters make many complex image-processing operations easy. By simply attaching a filter to an object, you can get many different visual effects: glows, shadows, blurs, sharpening, and more. Until Flex 4, though, there was a slight problem with these filters: they were all you got. If you liked the approach of filters, but wanted to apply some custom image-processing algorithm not achievable with the various filter classes that Flex provided, you were out of luck</p>"
              "<p><a href=\"http://www.dredwerkz.cz\">Dr3dweRkZ</a></p>"
              "<p align=\"justify\">In Flex 4, however, you can use a pixel shader with a ShaderFilter to filter your Flex object. A pixel shader is a small program, written using Adobe's Pixel Bender Toolkit. A shader is run for every pixel of an image, computing its resulting value from various input images and parameters.</p>"
              "<p align=\"justify\">The Grayer application lets the user drag the slider back and forth, changing the image from completely grayscale (when the thumb is on the left) to its original color version (when the thumb is on the right). The grayscaler shader used by this Flex application takes an input image and a colorization parameter and produces an image which is a blend of the original image and the grayscale version of that image. The blend is determined by the colorization parameter, where a value of 1 results in the original color image and a value of 0 results in a completely grayscaled image.</p>"
              "<p align=\"justify\">The grayscale calculation is based on a standard formula which combines the red, green, and blue channels of the original image to produce a gray pixel of a similar intensity with the calculation graypixel = red*.11 + green*.33 + blue*.55. The shader works by operating on each pixel of the original image, multiplying it times the grayscale formula to derive the gray version of that pixel, then blending that gray version with the original color pixel in the proportion determined by the colorization parameter.</p>"
              "</body></html>"
    var scroll = ScrollBar {
        min: 0
        max: content.boundsInLocal.height
        vertical: true
        height: bind nodeH - 30 //30 is 2 * arcHeight
        translateX: bind nodeW - 12 //default scrollbar width
        translateY: 15
    var clip = ClipView {
        clipY: bind scroll.value
        node: content
        pannable: false
        width: bind nodeW - 12
        height: bind nodeH
    var node = Rectangle {
        x: bind nodeX, y: bind nodeY
        width: bind nodeW, height: bind nodeH
        arcWidth: 15, arcHeight: 15
        fill: Color.BLACK
        stroke: Color.RED
        strokeWidth: 2
        onMouseDragged: function(drag: MouseEvent): Void {
            if (drag.altDown) {
                nodeX = drag.x;
                nodeY = drag.y
            } else {
                nodeW = drag.sceneX;
                nodeH = drag.sceneY;
    var s: Stage = Stage {
        title: "Resizable HTML Node"
        scene: Scene {
            width: 512
            height: 512
            content: [node, clip, scroll]
    }

  • Problem using clipView

    In the code below, vbox has 31 lines of text. The clip view of height 200 shows lines 0 to 12.
    clipY of the clipview is bound to value of vertical scrollbar which is also 200 long.
    When scroller is dragged to the end of the scrollbar only line 19 is shown.
    Attempt to change the line
    clipY: bind sb.value to
    clipY: bind sb.value * 3
    shows all the lines but generates exception shown at the end.
    How to use scroller to display all lines in clipView?
    Thanks for any suggestions.
    ~Tushar
    import javafx.stage.Stage;
    import javafx.scene.Scene;
    import javafx.scene.layout.ClipView;
    import javafx.scene.text.Text;
    import javafx.scene.control.ScrollBar;
    import javafx.scene.layout.VBox;
    import javafx.scene.layout.LayoutInfo;
    import javafx.scene.layout.HBox;
    var vbox = VBox {
    content: for(i in [0..30])
         Text {
            content: "line {i}"
    var sb : ScrollBar = ScrollBar {
            vertical: true
            min: 0
            max:100
            layoutInfo: LayoutInfo {height: 200}
    var clipView : ClipView = ClipView { node: vbox clipX: 0
    clipY: bind sb.value
    layoutInfo: LayoutInfo {height: 200 width:100}
    pannable: false
    Stage {
            title : "MyApp"
            scene: Scene {
                    width: 400
                    height: 400
                    content: [
                    HBox { content: [
                   clipView, sb ]}
    }Exception in trigger:
    com.sun.javafx.runtime.AssignToBoundException: Cannot assign to bound variable
    at com.sun.javafx.runtime.location.FloatVariable.setAsFloat(FloatVariable.java:111)
    at javafx.scene.layout.ClipView.set$clipY(ClipView.fx:66)
    at javafx.scene.layout.ClipView$_SBECL.onChange(ClipView.fx:67)
    at com.sun.javafx.runtime.location.FloatVariable.notifyListeners(FloatVariable.java:146)
    at com.sun.javafx.runtime.location.FloatVariable.replaceValue(FloatVariable.java:94)
    at com.sun.javafx.runtime.location.SBECL.pushValue(SBECL.java:137)
    at cliptest.SimpleClip$_SBECL.compute(SimpleClip.fx:36)
    at cliptest.SimpleClip$_SBECL.compute(SimpleClip.fx:36)
    at com.sun.javafx.runtime.location.AbstractVariable.update(AbstractVariable.java:128)
    at com.sun.javafx.runtime.location.AbstractVariable.ensureValid(AbstractVariable.java:163)
    at com.sun.javafx.runtime.location.FloatVariable.getAsFloat(FloatVariable.java:177)
    at javafx.scene.layout.ClipView$_SBECL.compute(ClipView.fx:208)
    at com.sun.javafx.runtime.location.AbstractVariable.update(AbstractVariable.java:128)
    at com.sun.javafx.runtime.location.AbstractVariable.invalidate(AbstractVariable.java:142)
    at com.sun.javafx.runtime.location.AbstractLocation$2.onAction(AbstractLocation.java:234)
    at com.sun.javafx.runtime.location.AbstractLocation$2.onAction(AbstractLocation.java:228)
    at com.sun.javafx.runtime.location.AbstractLocation.iterateChildren(AbstractLocation.java:181)
    at com.sun.javafx.runtime.location.AbstractLocation.invalidateDependencies(AbstractLocation.java:254)
    at com.sun.javafx.runtime.location.AbstractLocation.invalidate(AbstractLocation.java:108)
    at com.sun.javafx.runtime.location.AbstractVariable.invalidate(AbstractVariable.java:140)
    at com.sun.javafx.runtime.location.AbstractLocation$2.onAction(AbstractLocation.java:234)
    at com.sun.javafx.runtime.location.AbstractLocation$2.onAction(AbstractLocation.java:228)
    at com.sun.javafx.runtime.location.AbstractLocation.iterateChildren(AbstractLocation.java:181)
    at com.sun.javafx.runtime.location.AbstractLocation.invalidateDependencies(AbstractLocation.java:254)
    at com.sun.javafx.runtime.location.FloatVariable.notifyListeners(FloatVariable.java:140)
    at com.sun.javafx.runtime.location.FloatVariable.replaceValue(FloatVariable.java:94)
    at com.sun.javafx.runtime.location.FloatVariable.setAsFloat(FloatVariable.java:113)
    at javafx.scene.control.ScrollBar.set$value(ScrollBar.fx:59)
    at com.sun.javafx.scene.control.ScrollBarBehavior.thumbDragged(ScrollBarBehavior.fx:174)
    at com.sun.javafx.scene.control.caspian.ScrollBarSkin$11.lambda(ScrollBarSkin.fx:180)
    at com.sun.javafx.scene.control.caspian.ScrollBarSkin$11.invoke(ScrollBarSkin.fx:180)
    at com.sun.javafx.scene.control.cas

    Below code throws exception?
    import javafx.stage.Stage;
    import javafx.scene.layout.ClipView;
    import javafx.scene.text.Text;
    import javafx.scene.control.ScrollBar;
    import javafx.scene.layout.VBox;
    import javafx.scene.layout.LayoutInfo;
    import javafx.scene.layout.HBox;
    var vbox = VBox {
        content: for(i in [0..30]) {
            Text {
                content: "line {i}"
    var sb : ScrollBar = ScrollBar {
        vertical: true
        min: 0
        max: bind (vbox.height - sb.height)
        layoutInfo: LayoutInfo { height: 200 }
    var clipView = ClipView {
        node: vbox
        clipX: 0
        clipY: bind sb.value
        layoutInfo: LayoutInfo { height: 200 width:100 }
        pannable: false
    Stage {
        title : "MyApp"
        scene: Scene {
            width: 400
            height: 400
            content: [
                HBox {
                    content: [ clipView, sb ]
    }

Maybe you are looking for

  • Inspire 5200 5.1 - Can it run Xbox 360??

    I have the Inspire 5200 5.1 system on my PC. I can run the Xbox 360 through the PC by running the audio outputs through the 'Line In' port on my sound card. This is probably not 5.1 but it is good enough for what little I use the Xbox. However I woul

  • Is the new forum harder to navigate?

    I haven't been here in a few months. For years in was my regular stop 4-5 times a day.  Is it me or is the new forum very confusing and a real hassle to navigate?  I mean it was a real pain just to post this!

  • Setting Default Outlook Signature By Group Policy

    Hi I am attempting to standardise our company's email signature for all users. A contact supplied me with a VBA script which generates a signature based on the user's AD information. This works great but I would like group policy to set this signatur

  • This Should Be Called User Error Discussion

    I received my 60 gb black ipod this morning. I successfully loaded about 25 gb worth of music in about a half hour to 45 minutes. I also loaded the entire family guy that i encoded in videora ipod coverter, settings sp/320x240/768 kps stereo/128kps.

  • Form freezing issue forms 11g

    Hi All, In Oracle forms 11g, after selecting radio button, press any key from keyboard form will goes unresponsive mode(freeze). I was tried to catch event firing while pressing a key from keyboard using debugging and Trace events , but it not showin