Results 1 to 2 of 2
  1. #1
    waysgoose is offline Member
    Join Date
    Jul 2010
    Posts
    3
    Rep Power
    0

    Default Getting info from a GUI

    Hello all,

    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.

    Justin

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

    Default

    The problem I'm having is writing a condition that checks to see if the user has entered text into the JTextArea.
    DocumentListener

    I'm thinking I need some kind of loop structure that checks to see if there is text to send.
    No, you don't.

    And it's a strange chat program that starts sending as a user starts typing. With my typing skills, I would consider it unusable.

    db

Similar Threads

  1. SCJP 1.5 info
    By ajeeb in forum New To Java
    Replies: 1
    Last Post: 02-06-2009, 01:04 PM
  2. INFO About JDK1.6
    By ravi in forum New To Java
    Replies: 2
    Last Post: 11-03-2008, 02:30 PM
  3. Looking for some info.
    By Ragster in forum JDBC
    Replies: 2
    Last Post: 01-17-2008, 05:19 PM
  4. release info
    By venkatashiva in forum Java Software
    Replies: 3
    Last Post: 01-01-2008, 05:25 AM
  5. JVM Info
    By kishi in forum Advanced Java
    Replies: 0
    Last Post: 11-16-2007, 01:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •