I'm writing a very simple application in Javafx where there is a single button with a textbox on the stage as one scene.Now,the behavior I want is that when I click the button I can load another scene with another button and a textbox on the stage and remove the button i clicked alongwith the previous textbox. So the click of a button should load a new scene on the stage. any hints on how i can do this ?
Following Eric's advice:i have this code,and its working the way I want.
var showScene1 = true;
var showScene2 = false;
var showScene3 = false;
def stage = Stage
{
title: "Hello World"
var scene1 =Scene
{
content:
[
Text {
font : Font {
size: 24
}
x: 10, y: 30
content: "HelloWorld from Scene1"
},
Button
{
text: "Click Me to change to Scene2 "
onMouseClicked: function( e: MouseEvent ):Void
{
showScene2 = true;
println("In scene 2");
}
}
]
}
var scene2 =Scene
{
content:
[
Text {
font : Font {
size: 24
}
x: 10, y: 30
content: "HelloWorld from Scene2"
},
Button
{
text: "Click Me to change to Scene3 "
onMouseClicked: function( e: MouseEvent ):Void
{
showScene1 = false;
showScene2 = false;
showScene3 = true;
println("In scene 3");
}
}
]
}
var scene3 =Scene
{
content:
[
Text {
font : Font {
size: 24
}
x: 10, y: 30
content: "HelloWorld from Scene3"
}
]
}
scene: bind if (showScene2) then scene2
else if (showScene1) then scene1
else scene3
}