It is a regression in new API.
Run the following sample:
----------------------------------------------------------------------------------------------------------------------------
import javafx.stage.*;
import javafx.scene.*;
import javafx.scene.shape.*;
import javafx.scene.paint.*;
import java.lang.Math;
import javafx.animation.Timeline;
import javafx.animation.KeyFrame;
class Particle{
public var x:Number;
public var y:Number;
}
class BrownianMotion extends CustomNode{
public var particles: Particle[];
public override function create (): Node {
return Group{
content:
for (particle in particles)
Circle{
centerX: bind particle.x
centerY: bind particle.y
radius: 2
fill: Color.BLACK
}
}
}
public function run(){
var dx = 6.0;
for (particle in particles){
particle.x += Math.random() * dx - dx / 2;
particle.y += Math.random() * dx - dx / 2;
}
}
}
var d = 400;
var N = 50;
var brownianMotion = BrownianMotion{
particles:
for (i in [1..N])
Particle{
x: Math.random() * d
y: Math.random() * d
}
}
Timeline {
repeatCount: Timeline.INDEFINITE
keyFrames : [
KeyFrame {
time : 16ms
action: function() {
brownianMotion.run();
}
}
]
}.play();
Frame{
title: "Brownian Motion"
width: d
height: d
closeAction: function () { java.lang.System.exit(0); }
scene: Scene{
content: brownianMotion
}
visible: true
}
----------------------------------------------------------------------------------------------------------------------------
The frame hangs.
Run the following sample:
----------------------------------------------------------------------------------------------------------------------------
import javafx.stage.*;
import javafx.scene.*;
import javafx.scene.shape.*;
import javafx.scene.paint.*;
import java.lang.Math;
import javafx.animation.Timeline;
import javafx.animation.KeyFrame;
class Particle{
public var x:Number;
public var y:Number;
}
class BrownianMotion extends CustomNode{
public var particles: Particle[];
public override function create (): Node {
return Group{
content:
for (particle in particles)
Circle{
centerX: bind particle.x
centerY: bind particle.y
radius: 2
fill: Color.BLACK
}
}
}
public function run(){
var dx = 6.0;
for (particle in particles){
particle.x += Math.random() * dx - dx / 2;
particle.y += Math.random() * dx - dx / 2;
}
}
}
var d = 400;
var N = 50;
var brownianMotion = BrownianMotion{
particles:
for (i in [1..N])
Particle{
x: Math.random() * d
y: Math.random() * d
}
}
Timeline {
repeatCount: Timeline.INDEFINITE
keyFrames : [
KeyFrame {
time : 16ms
action: function() {
brownianMotion.run();
}
}
]
}.play();
Frame{
title: "Brownian Motion"
width: d
height: d
closeAction: function () { java.lang.System.exit(0); }
scene: Scene{
content: brownianMotion
}
visible: true
}
----------------------------------------------------------------------------------------------------------------------------
The frame hangs.
- relates to
-
JDK-8104938 Flocks sample brings cpu to 100%
- Closed
-
JDK-8106067 Changing Stage.scene.contents fails
- Closed