my dog learned polymorphism
The moose likes Swing / AWT / SWT and the fly likes PlainDocument and setDocument ??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "PlainDocument and setDocument ???" Watch "PlainDocument and setDocument ???" New topic

PlainDocument and setDocument ???

Tien Fu Liu

Joined: Jun 22, 2003
Posts: 8
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.
I agree. Here's the link:
subject: PlainDocument and setDocument ???
It's not a secret anymore!