Question

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()
                }
            }
        }
    }
}
Was it helpful?

Solution 2

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.

OTHER TIPS

you may want to have a look at

https://github.com/groovyfx-project/groovyfx/blob/develop/groovyfx/src/demo/groovy/CustomFieldDemo.groovy

which adds a new node type to the SceneGraphBuilder in essentially one line.

happy grooving' @mittie

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top