Client class:

```
public void connect(String user){
            try{
                host = socket.getInetAddress();
                socket = new Socket(host,port);

            }

        }

```

The Login class:

```
login.addActionListener(new ActionListener(){

        @Override
        public void actionPerformed(ActionEvent e) {

                String user = textInput.getText();
                Client client = new Client(username, 7777);
                client.setVisible(true);
                try{
                  client.connect(username);
                }
                catch(NullPointerException e){
                  e.printStackTrace();
                }
        }

    });

```

I'm calling the connect from the `Client` class and I tried catching the `NullPointerException` but I still get the error. I also tried inserting a `null check` instead of the `try and catch clause` 
I've tried to look around but I haven't found any answers. Can somebody tell me whats wrong please? What I want is the client to successfully connect.