Align and Justify don't work in VerticalLayout?

Hello everyone! I am not a professional developer, programming is just my hobby, so please help me figure out the following problem: the methods setAlignItems(Alignment.CENTER) and setJustifyContentMode(JustifyContentMode.CENTER) are not applied to the base component VerticalLayout:

public class RegistrationView extends VerticalLayout {
    UserRepository userRepository;
    EmailField emailField = new EmailField("Email");
    TextField usernameField = new TextField("Имя пользователя");
    PasswordField passwordField = new PasswordField("Пароль");
    PasswordField confirmPasswordField = new PasswordField("Подтверждение пароля");
    Button registerButton = new Button("Регистрация");
    Button loginButton = new Button("Войти");
    UserDTO userDTO = new UserDTO();
    PasswordEncoder passwordEncoder;

    public RegistrationView(UserRepository userRepository, PasswordEncoder passwordEncoder) {
        this.userRepository = userRepository;
        this.passwordEncoder = passwordEncoder;
        setAlignItems(Alignment.CENTER);
        setJustifyContentMode(JustifyContentMode.CENTER);
...


However, in another application everything is applied correctly:

public class RegistrationView extends VerticalLayout {
    TextField username = new TextField("Username");
    TextField password = new TextField("Password");
    TextField repeatPassword = new TextField("Repeat password");
    Button register = new Button("Register");
    UserRepository userRepository;
    UserDTO user = new UserDTO();
    PasswordEncoder passwordEncoder;


    public RegistrationView(UserRepository userRepository, PasswordEncoder passwordEncoder) {
        this.passwordEncoder = passwordEncoder;
        setAlignItems(Alignment.CENTER);
        setJustifyContentMode(JustifyContentMode.CENTER);
...

I’m just guessing here, and browser developer tools with help you here, but maybe your first VerticalLayout is not set to full size (or its parent is not)? So the contents are in fact aligned correctly, the VerticalLayout itself is just not any bigger than that.