Javafx节点只能在一个组中? [英] Javafx Nodes only able to be in one Group?

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

问题描述

我不确定这是不是bug还是我的JavaFX程序,但是我试图将节点添加到几个组(仅其中一个添加到场景中),并且遇到一个奇怪的情况,该节点会自动删除当我将它添加到另一个组时,它本身就来自上一个组.

I am not sure if this is a bug or not or just my JavaFX program but I am trying to add nodes to several Groups (only one of which is added to the scene) and encountering an oddity where the node will automatically remove itself from the previous group when I add it to another group.

我找不到任何有关对象只能属于一个组的文档,所以想知道它是否是错误或意图吗?我希望使用多个组来收集不同分组中的项目,以便我可以对整个组基于开/关应用高级效果(如MouseTransparency,Opacity等),而不是遍历作为某些子对象已经具有的列表的项目禁用MouseTransparency之类的功能(因此,我不想为最初没有MouseTransparency的项目重新打开它-通过将它们添加到组中很方便的功能).

I can't find any documentation on this talking about objects only being able to belong to one group, so was wondering whether its a bug or meant to be? I was hoping to use several groups to collect items in different groupings so that I can apply high level effects such as MouseTransparency, Opacity etc to whole groups on a on/off basis rather than iterate through items as a list where some child objects already have things like MouseTransparency disabled (therefore I don't want to turn it back on for items that originally did not have MouseTransparency - a feature that was handy by adding them to groups).

我注意到,您可以将组作为子级添加到其他组中.我尝试通过将组嵌套在主要显示的组下来解决我的问题,但是不得不放弃,因为如果它们包含在子组中,那么我无法对所有整体进行比较器排序,因为我只能对它们进行排序既可以在一个子组中,也可以将这些组按主组中的组进行排序,而不是对所有子组中的所有节点进行排序.

I note that you can add groups as a child to other groups. I have tried solving my problem by having this, groups nested under the main visually shown Group, but had to abandon that as I could not do a comparator sort on all the wholes if they are contained within sub-groups as I could then only sort either within a sub-group or sort the groups as groups within the main Group, rather than sorting all the nodes across all sub-groups.

谢谢

推荐答案

请参阅

如果程序将一个子节点添加到父级(包括组,区域等),并且该节点已经是另一个父级的子级或场景的根节点,则该节点会自动(无提示)从其节点中删除.前父母.

If a program adds a child node to a Parent (including Group, Region, etc) and that node is already a child of a different Parent or the root of a Scene, the node is automatically (and silently) removed from its former parent.

这篇关于Javafx节点只能在一个组中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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