Simultaneous JEditorPane/JtextField editing
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Simultaneous JEditorPane/JtextField editing

  1. #1
    Join Date
    Apr 2011
    Posts
    2

    Unhappy Simultaneous JEditorPane/JtextField editing

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

  2. #2
    Join Date
    Apr 2007
    Posts
    442

    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.

  3. #3
    Join Date
    Apr 2011
    Posts
    2

    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

    Thanks again :-)

    Cheers...!!!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center