Get String From Stream and append it in the TextArea
hi i wrote a simple network program in java and i have this problem
i when i get the data from the stream i can't append it in the TextArea
and this is the code :
/*
* Main.java
*
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package javaclient;
/**
*
* @author JAD
*/
import java.net.*;
import java.io.*;
import java.lang.Thread.*;
import java.awt.*;
import javax.swing.*;
import javax.swing.SwingUtilities;
import javax.xml.bind.ParseConversionEvent;
import java.util.*;
publicclass Mainimplements Runnable{
private javax.swing.JTextField IpAddress;
private javax.swing.JTextField Port;
private javax.swing.JTextArea Inputline;
private javax.swing.JTextArea ReciveText;
static BufferedReader in =null;
static PrintWriter out =null;
staticprivate Socket theClientSocket =null;
staticprivate String message ="";
public Main(JTextArea Inputline,JTextArea ReciveText , JTextField IpAddress,JTextField Port){
this.Port=Port;
this.Inputline=Inputline;
this.ReciveText=ReciveText;
this.IpAddress=IpAddress;
}
publicvoid Send()
{
out.println(Inputline.getText());
}
publicvoid run()
{
try{
//Instantiate a new Socket
theClientSocket =new Socket(IpAddress.getText(),Integer.parseInt(Port.getText()));
in =new BufferedReader(new InputStreamReader(theClientSocket.getInputStream()));
out =new PrintWriter(theClientSocket.getOutputStream(),true);
do
{
// Step 3: processing phase
try
{
// read message from server
final String message = in.readLine();
ReciveText.append(message +"\n");
}// end try
catch ( Exception ev )
{
// handle exception if error in reading server data
System.exit(1);
}// end catch
}while ( message !="TERMINATE" );
// Step 4: close connection
theClientSocket.close();
in.close();
out.close();
System.exit(1);
}// end try
catch (Exception error)
{
}// end catch
}
}
the problem is in this statment
ReciveText.append(message + "\n");
and the thing that me crazy the program exit when i send
TERMINATE
but the data doesn't appear in the TextArea
Any one here can help me

