克隆JavaFX节点? [英] Clone JavaFX Node?

查看:130
本文介绍了克隆JavaFX节点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在JavaFX场景构建器中创建了Node(AnchorPane),并且想知道如何克隆它.

I have created a Node (AnchorPane) in the JavaFX scene builder and was wondering how to clone it.

我看到了 JavaFX 2.0中的重复/克隆节点,但是我需要克隆Node而无需重新加载fxml.

I saw Duplicate/Clone Node in JavaFX 2.0 but I need to clone the Node without re-loading the fxml.

在JavaFX 2中有什么方法可以实现这一目标?

Is there any way to achieve this in JavaFX 2?

推荐答案

您可以将需要复制的组件放在单独的.fxml文件中.

You can place the component that needs to be duplicated in a separate .fxml file.

然后,您可以根据需要多次加载单独的文件,将节点添加到主场景中的相应根目录.

Then you can load the separate file as many times as needed adding the nodes to the appropriate root in the main scene.

此外,您可以将<fx:include source="..."/>元素编辑到主.fxml文件中,并包括单独的.fxml文件.然后,您仍然可以在JavaFX Builder中使用它.

Additionally you can edit an <fx:include source="..."/> element to the main .fxml file and include the separate .fxml file. You can then still work with it in the JavaFX Builder.

这篇关于克隆JavaFX节点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆