• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Detect String changes

 
Ranch Hand
Posts: 367
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
author
Posts: 4335
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to add an event listener that will handles events based on the changes you specify.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic