updating a shape in scene with a for loop using javafx
        Posted  
        
            by Susanta
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Susanta
        
        
        
        Published on 2010-03-12T21:07:05Z
        Indexed on 
            2010/03/15
            10:09 UTC
        
        
        Read the original article
        Hit count: 249
        
javafx
Following is a code fragment. I am updating a rectangle using a for loop when a button is pressed. This is a model for my ultimate intention of showing visualization of data model as it changes large number of times inside a for loop. It works but I see only one change. Now since I am changing the width randomly I should see large number of changes. It seems I am making a wrong assumption on something basic.
The code goes below:
 7 var rec: Rectangle = Rectangle {
 8             x: 10, y: 10
 9             width: 140, height: 90
10             fill: Color.BLACK
11         }
12 
13 Stage {
14     title: "MyApp"
15     scene: Scene {
16         width: 200
17         height: 200
18         content: [
19             rec,
20             Button {
21                 text: "Button"
22                 action: function () {
23                     for (i in [1..999]) {
24                         rec.width = 25 + java.lang.Math.random()*50;
25                     }
26                 }
27             }
28         ]
29     }
30 }
        © Stack Overflow or respective owner