克隆 JavaFX 节点?

Clone JavaFX Node?(克隆 JavaFX 节点?)
本文介绍了克隆 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 节点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)