Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #5501

Dynamic updation of a JTextArea

X-Received by 10.157.5.105 with SMTP id 96mr25011248otw.48.1481724991944; Wed, 14 Dec 2016 06:16:31 -0800 (PST)
X-Received by 10.157.37.59 with SMTP id k56mr6753589otb.3.1481724991835; Wed, 14 Dec 2016 06:16:31 -0800 (PST)
Path csiph.com!2.us.feeder.erje.net!feeder.erje.net!1.eu.feeder.erje.net!newspeer1.nac.net!border2.nntp.dca1.giganews.com!nntp.giganews.com!75no15234ite.0!news-out.google.com!c1ni2980itd.0!nntp.google.com!b123no16647itb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups comp.lang.java.gui
Date Wed, 14 Dec 2016 06:16:31 -0800 (PST)
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=47.31.250.37; posting-account=2uSbDQoAAACyUbc19SW_EKUfonn1OvrU
NNTP-Posting-Host 47.31.250.37
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <0f003cf3-2058-4286-8669-a75fe3f116c3@googlegroups.com> (permalink)
Subject Dynamic updation of a JTextArea
From abhprk3926@gmail.com
Injection-Date Wed, 14 Dec 2016 14:16:31 +0000
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
Lines 48
Xref csiph.com comp.lang.java.gui:5501

Show key headers only | View raw


I created a multi user chat system using sockets in java . everything works perfect but a little issue. the common jtextarea where i am supposed to display the chats ( its a app wherein all the users write messages and the message of all the users is visible in their chat space. Unfortunately the jtextarea is not updating itself whenever a client writes a message . I tried doing like System.out.print(contents of the common textarea) . In the command prompt every single message written is displayed , which means the code is working as intended . its just the textarea is not updating itself. i searched many forums even tried doing the update thing in a different thread than EDT but still i have the same problem. Can anyone help me out ? Here is the code .
 
     public void run()
       {
            try
                 {
                      DataInputStream in = new DataInputStream(client.getInputStream());    //client is the socket object
                      clientName = in.readUTF();                                                                      //clientname is a string which stores the name of the clients
 
                      s = "Joined";
                      SwingUtilities.invokeLater(new Runnable(){
                      public void run()
                      {
                           clientChat.ta.append(clientName+": "+s);         //clientchat is the name of the Client class and ta is the common textarea object which is declared as a static variable
                      }
                      });
 
                      while(!s.equals("terminate"))
                      {
                           s=in.readUTF();
                           SwingUtilities.invokeLater(new Runnable(){
                           public void run()
                           {
                                clientChat.ta.append(clientName+": "+s);
                            }
                           });
                      }
 
            }catch(Exception e){e.printStackTrace();}
     }
 
     every time a new client joins a new thread is created that acts as a server for the client. this is the class where the updation of the textarea is taking place. any help would be greatly praised.

Back to comp.lang.java.gui | Previous | NextNext in thread | Find similar


Thread

Dynamic updation of a JTextArea abhprk3926@gmail.com - 2016-12-14 06:16 -0800
  Re: Dynamic updation of a JTextArea Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2016-12-14 09:14 -0600
    Re: Dynamic updation of a JTextArea abhprk3926@gmail.com - 2016-12-14 08:44 -0800
      Re: Dynamic updation of a JTextArea abhprk3926@gmail.com - 2016-12-14 08:47 -0800
        Re: Dynamic updation of a JTextArea Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2016-12-14 15:15 -0600
          Re: Dynamic updation of a JTextArea Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2016-12-14 15:46 -0600
            Re: Dynamic updation of a JTextArea abhprk3926@gmail.com - 2016-12-14 14:09 -0800
            Re: Dynamic updation of a JTextArea abhprk3926@gmail.com - 2016-12-14 14:09 -0800
              Re: Dynamic updation of a JTextArea Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2016-12-14 16:23 -0600
              Re: Dynamic updation of a JTextArea Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2016-12-14 16:24 -0600
                Re: Dynamic updation of a JTextArea abhprk3926@gmail.com - 2016-12-15 00:18 -0800
                Re: Dynamic updation of a JTextArea Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2016-12-15 14:58 -0600
                Re: Dynamic updation of a JTextArea abhprk3926@gmail.com - 2016-12-16 02:23 -0800

csiph-web