2

我们在项目中使用GroovyFX来构建我们的用户界面。

它已经提供了对所有原生 UI 组件的支持,例如TextAreaand HTMLEditor,但我们也在构建一个自定义 UI 组件(实际上是 extends javafx.scene.web.HTMLEditor)。

在 GroovyFX 中实现对这个新组件的支持的最佳方式是什么?通过支持,我的意思是能够像任何其他组件一样调用它:

public static void main(String[] args) {

    def myArea

    GroovyFX.start {
        new SceneGraphBuilder().stage(width: 1024, height: 700, visible: true) {
            scene {
                vbox {
                    myArea = htmlEditor()
                }
            }
        }
    }
}
4

2 回答 2

3

你可能想看看

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

它基本上在一行中向 SceneGraphBuilder 添加了一种新的节点类型。

快乐开槽'@mittie

于 2012-02-22T06:18:22.097 回答
1

从 GroovyFX 用户列表中:

您需要创建一个新工厂才能让 SceneGraphBuilder 识别您的 myCustomEditor 节点。

但是解决您的问题的简单方法是编写:

场景 { vbox { myArea = node(new MyCustomEditor()) } }

使用 node() 您可以将作为节点的任何对象的实例添加到场景图中。

于 2012-02-09T09:46:09.967 回答