Arek Wróbel wrote:ServerFrameHandler fixed While loop. It wasn't needed. So here is a valid code.Sorry
Henry Wong wrote:
Swing isn't thread safe. You can't just change swing components in any thread. It may work, but it is not guaranteed to do so. Take a look at the SwingWorker and SwingUltilities classes to get the EDT (event dispatching thread) to make changes to Swing components.
Henry
Arek Wróbel wrote:Why there is no edit button ?
Norm Radder wrote:How are you trying to debug the code? I don't see enough print statements to show where the code is executing and what the values of variables are as the code executes.
I think you should.I didn't try to debug it.
Norm Radder wrote:
I think you should.I didn't try to debug it.
Debugging code that does not work is a very frequent part of a programmer's job. It is a necessary skill.
I use print statements that show where the code is executing and what the values of variables are as the code executes. Knowing what is happening when the code executes helps you find the problem so it can be fixed.
how to add those print statetmens,
Norm Radder wrote:
I think you should.I didn't try to debug it.
Debugging code that does not work is a very frequent part of a programmer's job. It is a necessary skill.
I use print statements that show where the code is executing and what the values of variables are as the code executes. Knowing what is happening when the code executes helps you find the problem so it can be fixed.
Does the server handle more than one client? What does the server do while handling a client? How does it get ready for the next client?
Norm Radder wrote:What is printed on the console when the program is executed?
Where does the second client send a message that the server does not receive?
Connection accepted from ...
Norm Radder wrote:OK that's a start. What happens after this is printed:
Connection accepted from ...
Arek Wróbel wrote:
Norm Radder wrote:OK that's a start. What happens after this is printed:
Connection accepted from ...
The object is created and method is invoked.
After that a new Thread is created in class SwingServerFrameHandler:
Code for handleServer():
Then starts the run method if i am right
Norm Radder wrote:
Then starts the run method if i am right
Add some print statements to show where the execution is doing. If values are read from a stream, print them.
No need to copy and paste another copy of the code. One is enough. What is needed is a copy of the console containing what was printed so we can see where the code was executing.
And if nothing was printed, we know that the execution hung or was blocked before it got to that print statement.
Norm Radder wrote:
Then starts the run method if i am right
Add some print statements to show where the execution is doing. If values are read from a stream, print them.
No need to copy and paste another copy of the code. One is enough. What is needed is a copy of the console containing what was printed so we can see where the code was executing.
And if nothing was printed, we know that the execution hung or was blocked before it got to that print statement.
know that text area changes when second client sends a message but it doesn't show up in this area.
Norm Radder wrote:
know that text area changes when second client sends a message but it doesn't show up in this area.
Sorry, I don't understand that.
"text area" changes - what is that?
"in this area" - what does that mean?
Norm Radder wrote:Does this describe what happens when the code executes?
The server receives the text from the client
the server attempts to show that text in a textarea
the text does NOT show in the textarea
Norm Radder wrote:Can you post the current contents of the classes you are working with?
Norm Radder wrote:The posted code uses 3rd party packages: org.netbeans.lib.awtextra
Can you remove them and only use standard java se classes?