public FXGLMenu(GameApplication app, MenuType type) { this.app = app; this.type = type; this.listener = FXGL.getMenuHandler(); getContentRoot().getChildren().addAll( createBackground(app.getWidth(), app.getHeight()), createTitleView(app.getSettings().getTitle()), createVersionView(makeVersionString()), menuRoot, contentRoot); // we don't data-bind the name because menu subclasses // might use some fancy UI without Text / Label listener.profileNameProperty().addListener((o, oldName, newName) -> { if (!oldName.isEmpty()) { // remove last node which *should* be profile view getContentRoot().getChildren().remove(getContentRoot().getChildren().size() - 1); } getContentRoot().getChildren().add(createProfileView(getLocalizedString("profile.profile")+": " + newName)); }); }