Friday December 12, 2008
Linux & JavaFX Tooling in NetBeans IDE
Follow Weiqi Gao's latest instructions (which I found out about thanks to Jim Weaver today) and you too will be able to develop JavaFX applications in NetBeans IDE, even though you're using Linux (in my case, Ubuntu):
Only Media support doesn't work yet, but that's part of the SDK, unrelated to the NetBeans IDE tooling support, which I now have working perfectly on Ubuntu.
And here's my simple code sample for today, note especially the line in bold:
import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.scene.paint.Color;
import javafx.scene.Scene;
import javafx.scene.shape.Circle;
import javafx.stage.Stage;
var color = Color.YELLOW;
Stage {
title: "Application title"
width: 250
height: 250
scene: Scene {
content: [
Circle {
centerX: 100,
centerY: 100
radius: 40
fill: bind color
}
]
}
}
Timeline {
repeatCount: Timeline.INDEFINITE
keyFrames: [
KeyFrame {
time: 5s
canSkip: true
values: [
color => Color.GREEN
]
}
]
}.play()
The "fill" property of the circle is bound to the "color" variable, which is used in the Timeline, changing gradually to green.
So here's how you'd make the circle move as it changes color (only the changes are in bold):
var color = Color.YELLOW;
var posX = 100;
Stage {
title: "Application title"
width: 250
height: 250
scene: Scene {
content: [
Circle {
centerX: bind posX,
centerY: 100
radius: 40
fill: bind color
}
]
}
}
Timeline {
repeatCount: Timeline.INDEFINITE
keyFrames: [
KeyFrame {
time: 5s
canSkip: true
values: [
color => Color.GREEN
posX => 200
]
}
]
}.play()
Similarly, you can bind the radius to a variable and then change it in the Timeline. This means the circle will become larger which, in turn, creates the impression that it is coming closer and closer to the user of the application.
Dec 12 2008, 05:28:52 AM PST Permalink


