If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Hybrid View

Simultaneous JEditorPane/JtextField editing

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...

Re: Simultaneous JEditorPane/JtextField editing

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.

Re: Simultaneous JEditorPane/JtextField editing

Hi Londbrok,

Thanks a lot for the reply.

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,

[1] Client edits the document
[2] Client send the change notification (including the change itself) to the server( i.e the group leader)
[3] 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

* The Perfect Platform for Game Developers: Android
Developing rich, high performance Android games from the ground up is a daunting task. Intel has provided Android developers with a number of tools that can be leveraged by Android game developers.

* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.