Okey , This is suppose to be a chat and server program and I am down to the last part but I cant seem to figure this out.
I Use the JtextField to get the Input from the user and it is suppose to hold it until the sent button is pressed. But when I pressed it the button gets stucked for a few second and it sends a bunch of message out and I cant figure out what is wrong with the code

private void sendButton()
   {
	 //  this is called by the send button 
      class Sentmessage implements ActionListener
      {
         public void actionPerformed(ActionEvent event)
         {
        	
        	 try
             {  
        		 streamOut.writeUTF(ChatInput.getText());
        		 streamOut.flush();
             
             }
             catch(IOException ioe)
             { 
            	 System.out.println("Sending error: " + ioe.getMessage());
                stop();
             }
         }
      }
      Sentmessage listener = new Sentmessage();
      send.addActionListener(listener);
   }

that is what is called

public void run()
   {  while (thread != null)
      {  
	   
	   sendButton();
      }
   }

Is this something to do with the thread?

while (thread != null)
{

What is that ? It looks like infinite loop to me. why did you put the while loop there? Is that the entire code you have posted? what are the errors you are getting? Have you tried debugging your code from the error messages?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.