facendola diventare un Thread però adesso non mi aggiorna la textarea .
ecco il codice:
codice:
public class SocketClient extends Thread{
private boolean autorizzazione=false;
private Socket socket=null;
private DataInputStream input = null;
private DataOutputStream output = null;
private static boolean DEBUG = false;
private GUI frame=null;
public SocketClient() {
}
public void setGUI(GUI frame){
this.frame=frame;
}
public void run(){
FileConfig f=new FileConfig();
try{
frame.writeTextArea("Trying to connect.....");
f.readProperties();
socket=new Socket(InetAddress.getByName("localhost"),f.getPort());
input =new DataInputStream(new BufferedInputStream(socket.getInputStream()));
output = new DataOutputStream( new BufferedOutputStream(socket.getOutputStream()));
output.flush();
output.writeInt(10);
output.flush();
String x=input.readUTF();
if(x.equals("OK")){
output.writeInt(f.getIDShip());
output.flush();
String r=input.readUTF();
if(r.equals("ACK")){
frame.writeTextArea("Server authorization done. Client identified");
autorizzazione=true;
frame.setEnabledButton5();
///frame.refresh();
}
}
}catch (IOException e) {
System.err.println((e.getMessage()));
if(e.getMessage().equals("Connection refused: connect"))
frame.writeTextArea("Connection refused");
else
frame.writeTextArea("Problem with configuration file");
}catch(Exception eof){
System.err.println(eof.getMessage());
}
f=null;
}
public boolean getAutorizzazione(){
return autorizzazione;
}
}
il metodo run() riesce a stampare il messaggio "Trying to connect....." ma poi non stampa gli altri.
tulipan