@Override
    public void actionPerformed(ActionEvent e) {
        Object source = e.getSource();
        String login = loginField.getText().trim();
        String password = passwordField.getText().trim();

        if (!checkFields(login, password)) {
            return;
        }

        User user = null;
        if (source == enterButton) {
            user = onEnter(login,password);
        }
        if (source == registerButton) {
            user = onRegister(login,password);
        }
        if (user == null) {
            return;
        }
        mainFrame.dispose();
        new MainWindow(user);
    }