Groups | Search | Server Info | Keyboard shortcuts | Login | Register
Groups > comp.lang.java.gui > #5501
| Newsgroups | comp.lang.java.gui |
|---|---|
| Date | 2016-12-14 06:16 -0800 |
| Message-ID | <0f003cf3-2058-4286-8669-a75fe3f116c3@googlegroups.com> (permalink) |
| Subject | Dynamic updation of a JTextArea |
| From | abhprk3926@gmail.com |
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 | Next — 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