• Post Reply Bookmark Topic Watch Topic
  • New Topic

Simultaneous JEditorPane/JtextField editing using threads

 
Niranga De Silva
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...!!!
 
Stanislav Lapitsky
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They have to share model somehow. In case of JTextComponents the model is Document. And you have to kind of serialize the document. E.g. write to HTML for HTMLEditorKit and restore it reading from HTML to documnet.
 
Niranga De Silva
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Someone else said to me
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.


Seems like both of you are trying to tell me the same thing. So I will definitely try it.

Thanks a lot for the reply Stanislav..!!!

Cheers..!!!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!