• Post Reply Bookmark Topic Watch Topic
  • New Topic

Detect String changes  RSS feed

 
Mathias Nilsson
Ranch Hand
Posts: 367
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

When a user writes a text in a java Textbox I want to save it to a database. When someone else goes in and edit the text I want all the users to see exactly what has been edited? Red mark text or something like that



Can someone point me to a solution?

Thanks!
 
Scott Selikoff
author
Bartender
Posts: 4093
21
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to add an event listener that will handles events based on the changes you specify.
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Although java.awt.event.KeyListener and javax.swing.event.DocumentListener would do the trick, these catch any change - if you keep typing you get multiple events, and therefore multiple database updates. Quite costly.

In this case, a combination of one of above and java.awt.FocusListener would be better - when the text is changed you set some flag, and then when you get a focusLost event, you should update the database if the value has changed.
 
Paul Clapham
Sheriff
Posts: 22841
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At one time I wrote an Undo manager for Swing text fields that combines adjacent edits (such as typing "abc" or holding down the delete key) into single edits. I could post that code from my home computer tonight if you think it would help. Let me know if you want it. Of course you'd still have to write the code that interpreted the edits as such and applied the appropriate colours.
 
Mathias Nilsson
Ranch Hand
Posts: 367
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your replies everyone.

My problem is that I'll have to mark the updated text.

Ex

An English makes a master of a text.
A Spanish translate the text
English master is updated
The spanish will only see what has been updated since last time. Not go thrue all rows again.

Is there an event that support this or do I have to count the characters and what text that has been deleted. NOTE: this is an applet.

// Mathias
[ November 15, 2005: Message edited by: P.W Mathias Nilsson ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!