私はJavafxで非常に単純なアプリケーションを書いています.1つのシーンとしてステージ上にテキストボックスを持つ単一のボタンがあります.今、私が望む動作は、ボタンをクリックすると別のボタンとテキストボックスで別のシーンをロードできることです.ステージで、前のテキストボックスと一緒にクリックしたボタンを削除します。ボタンをクリックすると、ステージに新しいシーンが読み込まれます。これを行う方法についてのヒントはありますか?
エリックのアドバイスに従って、私はこのコードを持っており、私が望むように動作しています。
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
}