I'm pretty new to Java programming, and I've got a problem I just can't seen to solve, or get past.
I'm trying to write a chat program that is made from 3 classes; a GUI class, a send class and a receive class. This is how my instructor wants it done. The program is to use threads. I have had very minimal experience with threads.
I'm writing the send class at the moment. What I want to do is take the text the user enters into a jTextArea in the GUI and send it from the send class to another socket.
The problem I'm having is writing a condition that checks to see if the user has entered text into the JTextArea. If there is text, the send class takes that text and sends it over the socket. I'm thinking I need some kind of loop structure that checks to see if there is text to send. Once there is text to send the loop is stopped, and the text is sent.
In my GUI, once text is entered it is copied to a string, and the JTextArea is then set to blank. I have a method called getText() that returns that string. Everytime I write a loop in my send class that uses getText() as part of a condition, I end up in an infinite loop type situation, regardless of any text entered.
I would appreciate any and all help. I don't expect anyone to write code for me; I want to do it myself. But could you please explain where I am going wrong, and which particular topics I should study up on.
Thanks everyone in anticipation of your help.