- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
看下面的代码:
public static void main(String[] args) {
Group group1 = new Group();
Group group2 = new Group();
Label label = new Label("test");
group1.getChildren().add(label);
group2.getChildren().add(label);
System.out.println("Size group1: " +group1.getChildren().size());
System.out.println("Size group2: " +group2.getChildren().size());
}
如果标签被添加到 group2,它会自动从 group1 中删除。有谁知道这是为什么?
到目前为止,我不需要额外的功能,例如来自组类的边界,并使用一个简单的 ArrayList 来存储对标签对象的引用。
最佳答案
A node may occur at most once anywhere in the scene graph. Specifically, a node must appear no more than once in all of the following: as the root node of a Scene, the children ObservableList of a Parent, or as the clip of a Node.
...
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.
...
It is possible to rearrange the structure of the scene graph, for example, to move a subtree from one location in the scene graph to another. In order to do this, one would normally remove the subtree from its old location before inserting it at the new location. However, the subtree will be automatically removed as described above if the application doesn't explicitly remove it.
当 Node
添加到 Scene
时,JavaFX 系统会在场景图中的那个位置设置和管理特定于该节点的属性。一个示例是由父布局管理器及其约束确定的节点位置。另一种是从父节点继承的css样式集。这两种数据都可能因节点在场景图中的位置而异。
如果系统允许您也将同一节点放置在场景图中的另一个位置,它将覆盖为第一个位置确定的系统计算属性。一切都会变得非常困惑 - 导致程序难以推理并具有细微的错误。
关于list - JavaFX getChildren() 列表行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13567802/
看下面的代码: public static void main(String[] args) { Group group1 = new Group(); Group g
我正在尝试制作一个创建棋盘的 javafx 程序。但是,当我尝试运行我的程序时,它会在这一行中抛出异常:optionsPane.getChildren().addAll(optionsPane, n_
例如,当我们向 Pane 添加新按钮时,我们需要编写以下代码: StackPane pane = new StackPane(); pane.getChildren().add(new Butto
我创建了一个单独的类来在 JavaFX 中设置网格。类如下: public class Grid { GridPane gp = new GridPane(); //sets grid (10
看下面的代码: public static void main(String[] args) { Group group1 = new Group(); Group g
我对 Java 比较陌生,尤其是 Javafx 和 GUI。我一直在研究这段代码,但我在理解最后一行正在做什么时遇到了一些困难。我知道倒数第二行是将所有组件添加到容器“p”中,但是当您在前面没有容器的
XML: .... PD1 PD2 PD3 ..
我想获取一个元素的所有子元素,包括文本节点。我如何在 MooTools 中执行此操作? mootools.net 上的文档明确指出 getChildren() 不包括文本节点。 最佳答案 您可以使用标
这是我的 xml: 例子: 987 0 F0F8DJH348DJ 46446
好吧,我不确定我是否在正确的地方问这个问题,但我希望这里有人可以帮助我。所以,我是 Java 初学者,我正在尝试制作 JavaFX 应用程序,但我的布局 1“getChildren.addAll(la
当我尝试调用 getChildren() 时在 mediapipeline 上其中运行了我的自定义模块端点我收到此异常: org.kurento.client.internal.server.Prot
为什么有时我们使用 getChildren() add() 而其他时候我们直接使用 add() es: https://docs.oracle.com/javafx/2/get_started/for
此代码不允许在我的窗口中绘制线条...我在 fxml 文件中只有一个简单的 Pane ,其 fx:id 为 hi 用于测试。没有错误,该行根本没有出现。我也用盒子和圆圈试过这个。我真的需要帮助,这是一
我有一个小问题,当我想添加文本字段时,VBOX 的按钮和标签我有一个错误:ObservableList 中的 addAll() 不能应用于: 在这个地方:vBox.getChildren().addA
如果我在 XML 文件上运行以下 python(请参见 Q 底部): import xml.etree.ElementTree as ET tree = ET.parse('C:\\temp\\tes
我清除了所有子项的网格 Pane ,然后再次将子项添加到网格 Pane 中,但它说存在重复项。 public void render(){ boardPane.getChildren().cl
我试图读取我之前在Excel工作表中插入的图像及其位置与此代码,它在我的机器上工作正常,但是当我将代码迁移到另一台电脑时,我在工作表中遇到空指针异常。 getDrawingPatriarch.getC
上下文 我正在为一个小游戏创建一个 GUI。游戏有一个开始屏幕。当玩家点击开始时,舞台场景从菜单场景变为游戏场景。新的游戏场景以 Group 作为父级,并包含一些元素,例如玩家的得分和姓名,所有这些元
我有一个 Group 子类的实例,我正在向其中添加其他 Groups。其中一个组是一个组的子类,它有一个方法 getCollision() .在那种方法中,我正在运行 for each循环检查该组父级
本文整理了Java中com.yahoo.text.XML.getChildren()方法的一些代码示例,展示了XML.getChildren()的具体用法。这些代码示例主要来源于Github/Stac
我是一名优秀的程序员,十分优秀!