Java Reference
In-Depth Information
+ "broadcast that night, the crew took turns reading from "
+ "the Topic of Genesis, closing with a holiday wish from "
+ "Commander Borman: \"We close with good night, good luck, "
+ "a Merry Christmas, and God bless all of you -- all of "
+ "you on the good Earth.\"";
// Reference to the Text
Text textRef = new Text(message);
textRef.setLayoutY(100);
textRef.setTextOrigin(VPos.TOP);
textRef.setTextAlignment(TextAlignment.JUSTIFY);
textRef.setWrappingWidth(400);
textRef.setFill(Color.rgb(187, 195, 107));
textRef.setFont(Font.font("SansSerif", FontWeight.BOLD, 24));
// Provides the animated scrolling behavior for the text
TranslateTransition transTransition = new TranslateTransition(new Duration(75000), textRef);
transTransition.setToY(-820);
transTransition.setInterpolator(Interpolator.LINEAR);
transTransition.setCycleCount(Timeline.INDEFINITE);
// Create an ImageView containing the Image
Image image = new Image (" http://projavafx.com/images/earthrise.jpg " );
ImageView imageView = new ImageView(image);
// Create a Group containing the text
Group textGroup = new Group(textRef);
textGroup.setLayoutX(50);
textGroup.setLayoutY(180);
textGroup.setClip(new Rectangle(430, 85));
// Combine ImageView and Group
Group root = new Group(imageView, textGroup);
Scene scene = new Scene(root, 516, 387);
stage.setScene(scene);
stage.setTitle("Hello Earthrise");
stage.show();
// Start the text animation
transTransition.play();
}
}
Now that you've seen the code, let's take a look at its constructs and concepts in some more detail.
What Happened to the Builders?
If you were using JavaFX 2 before, you are probably familiar with the so-called builder pattern. Builders provide a
declarative style of programming. Rather than calling set() methods on a class instance to specify its fields, the
builder pattern uses an instance of a Builder class to define how the target class should be composed.
 
Search WWH ::




Custom Search