Groups | Search | Server Info | Keyboard shortcuts | Login | Register
Groups > comp.lang.java.gui > #5502
| From | Knute Johnson <nospam@rabbitbrush.frazmtn.com> |
|---|---|
| Newsgroups | comp.lang.java.gui |
| Subject | Re: Dynamic updation of a JTextArea |
| Date | 2016-12-14 09:14 -0600 |
| Organization | A noiseless patient Spider |
| Message-ID | <o2rnhu$sgf$1@dont-email.me> (permalink) |
| References | <0f003cf3-2058-4286-8669-a75fe3f116c3@googlegroups.com> |
On 12/14/2016 08:16, abhprk3926@gmail.com wrote:
> 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.
>
I don't see anything obvious in your code but I'm only seeing a piece of
it. I suggest you try making an SSCCE and duplicating your problem or
maybe it will help you discover an answer. Oh and formatting your code
a little more neatly would help too. Post an SSCCE here if you can't
get it to work.
--
Knute Johnson
Back to comp.lang.java.gui | Previous | Next — Previous in thread | Next in thread | Find similar
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