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()
}
}
}
}
}
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.