I am working on a project which requires to update a JEditorPane or JTextField simultaneously by multiple clients.
It is something like this.
. There are several users( i.e a group) with the same application which contains a JEditorPane.
. 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.
. 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...
You could consider a diff -like approach. The server would contain the model, being the text under editing. Handling it must be synchronized, clients send a changeEvent (such as simply: line number, text). Model updates the internal understanding of how the text should be, and sends it to the clients. Might be wise if you do not process new incoming changes, untill the current change event has been successfully sent out to clients.
Yes, I agree with you on "not to process new incoming changes, until the current change event has been successfully sent out to clients. ". My plan is,
 Client edits the document
 Client send the change notification (including the change itself) to the server( i.e the group leader)
 Server multicast it to other users by maintaining a queue of changes received
I recently got to know about "Document" object which I can get form "getDocument()" method. At the moment I am trying to add Document Listener to that Document to track the changes. It methods "changedUpdate", "removeUpdate" and "changedUpdate" methods.
If I could extract the altered part from the Document, I can send it through the Socket to the server. I have not tried it yet. It is just an idea :-)
Still I have to handle conflicts with that, otherwise all the changes will be replaced :-/.
Thanks a lot for the reply and I am looking forward to get more knowledge on this matter also