K
Kd
Hello,
I am new to java and I started off by writing a client/server based
tic-tac-toe game using Swing. I have run myself into the following
situation.
What I am trying to do:
My server wants print a dot (.) every few seconds on its GUI text area
when it is waiting for input from the client.
How I did it:
I have timeout set on the socket from where server is reading for the
client input. Upon timeout there is an exception and my catch block
will print(try to) a dot on the server GUI text area. And then it will
again go back to reading(waiting for) the client input.
Problem:
However out of my design flaw or whatever, this whole thing about
waiting for Client input and printing the GUI, is happening in the same
GUI thread.
So the User Inputs -> Server GUIThread ->Waits for Client->Timesout and
prints to the GUI->Wait for Client->Gets Client response->Prints some
other info to the GUI
Due to this the dot(.) that i m trying to print at time out is not
flushing on the GUI screen until the server gets the response from the
client.
Is there a way to go around this ? If no what would be a better design
for Client/Server GUI apps WRT java swing.
Thanks,
Kandarp
I am new to java and I started off by writing a client/server based
tic-tac-toe game using Swing. I have run myself into the following
situation.
What I am trying to do:
My server wants print a dot (.) every few seconds on its GUI text area
when it is waiting for input from the client.
How I did it:
I have timeout set on the socket from where server is reading for the
client input. Upon timeout there is an exception and my catch block
will print(try to) a dot on the server GUI text area. And then it will
again go back to reading(waiting for) the client input.
Problem:
However out of my design flaw or whatever, this whole thing about
waiting for Client input and printing the GUI, is happening in the same
GUI thread.
So the User Inputs -> Server GUIThread ->Waits for Client->Timesout and
prints to the GUI->Wait for Client->Gets Client response->Prints some
other info to the GUI
Due to this the dot(.) that i m trying to print at time out is not
flushing on the GUI screen until the server gets the response from the
client.
Is there a way to go around this ? If no what would be a better design
for Client/Server GUI apps WRT java swing.
Thanks,
Kandarp