File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

PlainDocument and setDocument ???

 
Tien Fu Liu
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi:
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 .
shared.setDocument(SharedDoc);
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic