I'd like to use a JavaFX program to echo the same holiday wish that the astronauts on the Apollo 8 mission extended 40 years ago. The program, as you'll see in the listing shortly, obtains the magnificant image below from the NASA website, so you'll be asked to confirm that you want to allow that. Click the Java Web Start link below the "Earthrise at Christmas" picture to start the program:
By the way, this will be the first example (a sort of Hello World/Earth program) in our upcoming Pro JavaFX book. Take a look at the source code for the program below to understand how it works:
/*
* HelloEarthRiseMain.fx - A JavaFX Script "Hello World" style example
*
* Developed 2008 by James L. Weaver jim.weaver [at] javafxpert.com
* as a JavaFX Script SDK 1.0 example for the Pro JavaFX book.
*/
package projavafx.helloearthrise.ui;
import javafx.animation.transition.*;
import javafx.animation.*;
import javafx.stage.Stage;
import javafx.scene.*;
import javafx.scene.effect.*;
import javafx.scene.image.*;
import javafx.scene.paint.*;
import javafx.scene.shape.*;
import javafx.scene.text.*;
import javafx.scene.transform.*;
var textRef:Text;
// Provides the animated scrolling behavior for the text
var transTransition = TranslateTransition {
duration: 60s
node: bind textRef
toY: -600
interpolate: Interpolator.LINEAR
repeatCount: Timeline.INDEFINITE
}
Stage {
title: "Hello Earthrise"
scene: Scene {
content: [
ImageView {
image: Image {
url: "http://www.nasa.gov/images/content/54427main_MM_image_feature_102_jw4.jpg"
}
},
Group {
transforms: bind Translate.translate(50, 180)
content: [
textRef = Text {
translateY: 100
textOrigin: TextOrigin.TOP
textAlignment: TextAlignment.JUSTIFY
wrappingWidth: 410
// Note that this syntax creates one long string of text
content: "Earthrise at Christmas: "
"[Forty] years ago this Christmas, a turbulent world "
"looked to the heavens for a unique view of our home "
"planet. This photo of Earthrise over the lunar horizon "
"was taken by the Apollo 8 crew in December 1968, showing "
"Earth for the first time as it appears from deep space. "
"Astronauts Frank Borman, Jim Lovell and William Anders "
"had become the first humans to leave Earth orbit, "
"entering lunar orbit on Christmas Eve. In a historic live "
"broadcast that night, the crew took turns reading from "
"the Book 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.\""
// The approximate color used in the scrolling Star Wars intro
fill: Color.rgb(187, 195, 107)
font: Font {
name: "Arial Bold"
size: 24
}
}
]
clip: Group {
content: [
Rectangle {
width: 410
height: 85
}
]
}
}
]
}
}
// Start the text animation
transTransition.play();
As always, if you have any questions, please leave a comment.
Happy Holidays/Merry Christmas!
Jim Weaver
JavaFXpert.com
one of the best if not the best series that has been, that purpose by God! I plead fan number 1 of the saga de star war ...
Posted by: kamagra online | April 22, 2010 at 06:17 PM
I'm facing a problem similar to Vaibhav. If I save the earthrise.jpg file under the compiled folder in my project directory & use url: "{__DIR__}earthrise.jpg" it works just fine. If I use url: "http://www.nasa.gov/images/content/54427main_MM_image_feature_102_jw4.jpg" or url: "http://projavafx.com/images/earthrise.jpg"
it just doesnt work. Surprising enough, the .mid file on the projavafx website opens & plays so it cant be a connectivity issue. I've tested using both Standard Execution & Webstart. I use IE 6 and XP SP2.
Posted by: javafxAmateur | February 15, 2010 at 04:42 AM
sorry for the late reply , although I follow your blog butit's really easy to miss these replies , sorry again,
and now your question
I am using Firefox in Windows Vista
Posted by: Account Deleted | April 29, 2009 at 06:02 PM
"The image is not loading inside netbeans , even if I run application in browser , however it runs fine through webstart by asking permission to connect, I am running this example as given in your book, is there any fix to avoid this"
vaibhav mishra,
What browser / OS are you using?
Thanks,
Jim Weaver
Posted by: Jim Weaver | April 06, 2009 at 04:07 PM