Hi,

I am working on a project which requires to update a JEditorPane or JTextField simultaneously by multiple clients.

It is something like this.
[1]. There are several users( i.e a group) with the same application which contains a JEditorPane.

[2]. There is a group leader for a group( note: there is an option to be a group leader in the same application) and each an every other user( i.e group member) will be connected to the group leader via individual sockets.

[3]. After connecting as a group every one can type anything into the JEditorPane and that content should be synchronized with the content of the others at the same time. So at the end there will be same content on the all the JEditorPanes.

This is lot similar to Google docs. I need to do it using a Java application. I have already implemented the group initiation part using sockets and it is perfectly connecting with each other on a wired LAN.

Synchronizing part is where i am struggling at the moment. If we forget about conflict handling for a moment and just focus on 2 users working on two separate paragraphs at the same time, what are the possible methods that I have to achieve this? Any suggestions please...


Thanks a lot in advance

Cheers...!!!

From the EditorPane you can get its EditorKit, and from that you can get the Document itself.
You can add a DocumentListener to the Document to be notified of all changes the user makes. Send those via the Socket connection. At the other end you can insert (or remove) the changes in the other Document.

Hi JamesCherrill,

Thanks a lot for the reply JamesCherrill..!!! I will try it and get back if it did not help me...

Thanks again

Cheers..!!

Hi JamesCherrill,

Your solution seems like working for me. I haven't applied it to the main project of mine but I tried it with a testing application.

Thanks a lot for the help...!!!! :)
Keep up the good work..!! :) :)

Cheers..!!!!

This question has already been answered. Start a new discussion instead.