Reputation: 4608
We are using GroovyFX in our project, to build our user interfaces.
It already provides support for all the native UI components, such as TextArea
and HTMLEditor
, but we are also building a custom UI component (that actually extends javafx.scene.web.HTMLEditor
).
What would be the best way to implement support for this new component in GroovyFX? By support I mean being able to call it like any other component:
public static void main(String[] args) {
def myArea
GroovyFX.start {
new SceneGraphBuilder().stage(width: 1024, height: 700, visible: true) {
scene {
vbox {
myArea = htmlEditor()
}
}
}
}
}
Upvotes: 2
Views: 645
Reputation: 31
you may want to have a look at
which adds a new node type to the SceneGraphBuilder in essentially one line.
happy grooving' @mittie
Upvotes: 3
Reputation: 4608
From the GroovyFX-users list:
You would need to create a new factory in order to get the SceneGraphBuilder to recognize your myCustomEditor node.
But the simple solution to your problem is to write:
scene { vbox { myArea = node(new MyCustomEditor()) } }
Using node() you can add an instance of any object that is-a node to the scene graph.
Upvotes: 1