This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "PlainDocument and setDocument ???" Watch "PlainDocument and setDocument ???" New topic
Author

PlainDocument and setDocument ???

Tien Fu Liu
Greenhorn

Joined: Jun 22, 2003
Posts: 8
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
 
subject: PlainDocument and setDocument ???