請看下面的代碼:的JavaFX的getChildren()列出行爲
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());
}
如果標籤被添加到組2就自動從1組中刪除。有誰知道這是爲什麼?
到現在爲止,我不需要額外的功能,例如並且使用一個簡單的ArrayList來存儲對標籤對象的引用。