私はJavaFXとGroovyFXにかなり慣れていません。
私は JavaFX で最初のフォームを作成しました。Groovy/Grails 開発チームに所属しているので、すぐにそれを GroovyFX に移植しました。
ページ レイアウトをモジュール化する方法、つまり、メソッドの下のノード定義を抽出する方法を知りたいGroovyFX.start()
です。
次の単純なレイアウトがあるとします。
start{
stage(title: 'GroovyFX Hello World', visible: true){
scene(width: 300, height: 100){
borderPane{
center(align: CENTER){
text "this is the center region"
}
}
}
}
}
start メソッドの下でコードをクロージャーに抽出できます。
start{
def renderCenter = {
text "this is the center region defined in a closure"
}
stage(title: 'GroovyFX Hello World', visible: true){
scene(width: 300, height: 100){
borderPane{
center(align: CENTER){
renderCenter()
}
}
}
}
}
しかし、私が欲しいのは:
class CenterRegion {
def render(){
text "this is the center region in a separate class"
// and other stuff
}
}
start{
stage(title: 'GroovyFX Hello World', visible: true){
scene(width: 300, height: 100){
borderPane{
center(align: CENTER){
CenterRegion.render()
}
}
}
}
}
GroovyFX でこれを達成するにはどうすればよいですか?
ありがとう