0
I am working on a project written in Java with a Client structure - Server.
My client consists of Swing Graphical Interfaces and the server working with multi-threads. But I’m at a point where I can’t go through with it. There is an action on the server where it sends a data (String) to the client every 10 seconds. The problem is at the moment when I will receive this data and set in a label located in a Jframe. I am not able to receive the data and set at the same time. Follow the section where I receive and I set the value:
while (cond) {
//Espera ate receber um dado do srv para ler
String line = in.readLine(),pedra;
//Verifica se incia com PEDRA. True = Pego valor, setText
if ( line.startsWith("PEDRA")) {
pedra = line.substring(6));
lblMostraDado.setText(pedra);
//Caso for BINGO fim de jogo
}else if( line.startsWith("BINGO")){
cond = false;
}
I’ve done a lot of tests and I’ve drawn some conclusions. When I run the above code in debug mode the values arrive from the server and are assigned to the label normally, but it is not updated in the window. Now when I remove this while, it receives only once the value of the server and gets arrow the value on the label and is updated on the screen, however I need to be always picking these values until the stop condition of the while comes.