Hello.

I write out a simple messaging client / server. I have already written a console application, which works fine but I wanted to write desktop application.
And there is a problem because when I create a connection to the program I got Exception.

I can say that the same code in the console is working properly.

Sorry for my english.

Here I start connecting:
Java Code:
     private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {  
      
            String sPort=jComboBox1.getSelectedItem().toString();  
            int port = Integer.parseInt(sPort);  
            try{  
            ServerSocket serverSocket = new ServerSocket(port);  
            jTextArea1.append("Server waiting for client on port " + serverSocket.getLocalPort()+"\n");  
            }  
            catch (Exception e){}  
            jTextArea1.append("Server waiting for connection \n");  
      
            new Thread (new newSocket(serverSocket,jTextArea1)).start();  
            jButton1.setEnabled(false);  
        }
And this is Thread where I got Exception
Java Code:
    class newSocket implements Runnable  
    {  
        public newSocket(ServerSocket s,JTextArea _area)  
        {  
            serverSocket=s;  
            jTextArea1=_area;  
        }  
      
        public void run()  
        {  
            try  
            {         
                Socket socket = serverSocket.accept();  //it doesn't work    
                jTextArea1.append("New client asked for a connection"); 
            } catch(IOException e){e.printStackTrace();  }  
        }  
      
        private JTextArea jTextArea1;  
        private ServerSocket serverSocket;  
    }
Exception:
Java Code:
Exception in thread "Thread-3" java.lang.NullPointerException
        at serwer.ClientSocket.run(SerwerView.java:317)
        at java.lang.Thread.run(Thread.java:619)