One scene to other - JavaFX
Monday Dec 01, 2008
Any middle or big application demands to change one window to other at some point of time. A window type of thing in JavaFX is represented by Scene and its each to switch between scene or to run multiple scenes.
Here is a small application in which clicking on image will put you in another window, written "Hello World"
package sample6;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.text.Text;
import javafx.scene.text.Font;
import javafx.scene.image.ImageView;
import javafx.scene.image.Image;
import javafx.scene.input.MouseEvent;
var s_new:Scene;
var s = Scene {
content: [
Text {
font: Font {
size: 24
}
x: 10,
y: 30
content: "HelloWorld"
}
]
};
var s1 = Scene {
content: [
ImageView {
image: Image {
url: "{__DIR__}im2.PNG"
}
onMouseClicked: function( e: MouseEvent ):Void {
s_new = s;
}
}
]
};
s_new = s1;
Stage {
title: "Application title"
width: 250
height: 280
scene: bind s_new
}
So, its simple, on mouse click, I have bind a scene variable with a new scene. That's it !
Tags: animation code javafx mouseclick scene windows















Vaibhav,
I am getting a Encountered "s_ne&q...
Oh I thought some typo somewhere in the FXpad...
Vaibhav,
I'm still having trouble.
ah you have to use NB 6.5 and FX 1.0. I am re...
Vaibhav,
I have NetBeans IDE 6.5 and it doesn't ha...
you have to wait for 2 more days :). JavaFX 1.0 go...
you have any Idea of how to go back from the "...