import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
public class GroupTest extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
Group group1 = new Group();
Group group2 = new Group();
Button button = new Button("Test");
group1.getChildren().add(button);
group2.getChildren().add(button);
// Group继承自Parent,Parent继承自Node,非Parent的Node只能真实地加在最后一个Parent中
System.out.println(group1.getChildren().size());
group1.setVisible(false);
System.out.println(group2.getChildren().size());
group1.setVisible(false);
Pane pane = new Pane();
pane.getChildren().add(group1);
pane.getChildren().add(group2);
primaryStage.setScene(new Scene(pane, 200,300));
primaryStage.show();
}
}