Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

PlainDocument and setDocument ???  RSS feed

Tien Fu Liu
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I try to implement a distributed concurrent text editor with RMI.
My server can send the edit command to every client.
Edit command includes edit type(insert or remove), offset, length, string, attribute.

So at first I use a JTextArea as my text area.
After my client connects to server, I use another class SharedDocument which extends PlainDocument to override insertString and also remove.
And in those two methods, I create another class Edit Command to know edit type, offset, length, string, and also attribute.

So I can send the edit command to server and my server will help me to broadcast those edit command to every client.

The following is how I implement this idea.
1. Create JTextArea.
JTextArea shared = new JTextArea();
2. After my client connects to server, create SharedDocument . SharedDocument SharedDoc = new SharedDocument();
3. And then set document .
4. After each client receive EditCommand, apply the corresponding edit to their individual JTextArea.
for example, if the edit command is insertString, then I apply the corresponding offset, string, attribute to the JTextArea as
SharedDoc.insertStringLocal(offset, str, a);
And insertStringLocal will invoke super.insertString(offset,str,a)

My question is after I insert some string from one client, then this client doesn't insert any string on JTextArea.
It seems dead and needs to be killed.
So could you please help me with this problem...

Thanks a lot.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!