Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6974303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:13:11+00:00 2026-05-27T17:13:11+00:00

I am making a simple chat GUI and I have written both a server

  • 0

I am making a simple chat GUI and I have written both a server and GUI client and I can send a message from the client GUI to the server.

My problem is with receiving message from a server on frame.
When I use an infinite loop the frame is locked. I don’t know how I should split the thing to get any message displayed on JTextArea.
My question is:
Is there any way to split frame to handle the ‘send’ and ‘receive’ information from a server?

My GUI consists of a JTextField, JTextArea and JButton.

When press the JButton the text from JTextField is sent to the server by:

String u = jTextField.getText(); 
out.writeUTF(u);

But I don’t know what I should do to get JTextArea lessen all time for coming information by:

msg = in.readUTF();
jta.append(msg + "\n");

//

Should the thread be a class or component in GUI class because i have made thread evrything seems to be working but massage don’t apear on jTextField. I made thread like in server I did in same file but is not working:

    class bacgroundTask extends Thread{
static String msg;
static JTextArea jta;
static DataInputStream in;
public void run(){
        while(true){
            try{
            msg = in.readUTF();
            jta.append(msg + "\n");
            }
            catch(IOException ioe){}}}}

//

Hi it’s again me i try use the invokelater method but the frame frezze when is executed i can’t clik send button or type in text in jtextfield. Could any body explain me a bit more about them methods and are they right in my case.

I have tried with and without while stetment.

       SwingUtilities.invokeLater(
        new Runnable(){
            public void run(){
                while(true){
                try{
                    msg = in.readUTF();
                    jta.append(msg + "\n");
                    jta.revalidate();
                }
                catch(IOException ioe){

                }}}});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T17:13:12+00:00Added an answer on May 27, 2026 at 5:13 pm

    You need to run an infinite receive loop on a background thread.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am making a TCP chat server from a simple tutorial I found and
I'm making simple XMPP client using Jabber-Net. To send simple message i'm using a
I am making simple one on server side & one on client side application
I'm trying to make a simple chat server in Java. Now I have a
I'm making a simple cross platform chat program. I'm using wXWidgets for the GUI
I am building a simple ajax chat client for a school project and have
If I'm making a simple grid based game, for example, I might have a
I'm making a simple chat program for me and my friends as a tech
I am making a simple chat application and I am trying to find out
I'm making simple game with very simple thread (1 sec delay) got problem with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.