Yesterday I challenged the readers of this blog with JavaFX Puzzler #1. Please take a look at that post for the requirements, as well as the selection criteria for the winners (first correct solution from a JavaFX with Passion! student and first correct solution from someone that isn't enrolled in that course).
I am pleased to announce that the winners of this "Major Award" are Jonathan Share and "acw1668 from HK", and that they each will receive a coupon with which they can get the Pro JavaFX early access eBook for free. Also, the screenshot of the "Major Award" from the comedy movie "A Christmas Story" has been included above.
Here is the screenshot and code for the example solution:
package javafxpassionpuzzler1;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.text.*;
import javafx.ext.swing.SwingSlider;
Stage {
var angle:Integer = 0;
title: "Rotate Puzzler"
scene: Scene {
width: 300
height: 200
content: [
Text {
translateX: 90
translateY: 90
rotate: bind angle
textOrigin: TextOrigin.TOP
fill: Color.BLUE
content: bind "Angle: {angle}"
font: Font.font("sans serif", FontWeight.BOLD, 24)
},
SwingSlider {
translateX: 50
maximum: 360
value: bind angle with inverse
}
]
}
}
Note that the rotate instance variable inherited by the Text class causes the node to be rotated around the center of the node. Another approach used in reader solutions was to place a Transform.rotate() function in the transforms instance variable. A downside of the latter approach is that the code must calculate the center of the node.
Please leave a comment if you have any questions about this solution. Congratulations to Jonathan Share and "acw1668 from HK"!
Regards,
Jim Weaver
JavaFXpert.com
I'm really surprised that I'm so lucky to win the challenge. Thanks Jim for your wonderful book.
Posted by: acw1668 from HK | March 24, 2009 at 09:32 PM
Jonathan Share and "acw1668 from HK" congratulations and thanks to Jim for the challenge.
Posted by: César Amaya | March 24, 2009 at 01:08 PM