Reputation: 3169
There is a possibility to get a list of changes in JTextArea
in simple way?
I mean that I want to retrieve all text which were typed/showed in JTextArea
, something like ReDo/UnDo. Have the possibility to back, like "CTRL + Z"
Upvotes: 2
Views: 259
Reputation: 573
Back in the days I have used UndoManager to manage swing text component changes.
You can find api here: Oracle JavaDoc UndoManager
And usage example here: Java2s example UndoManager
HTH
Update:
UndoManager extends CompoundEdit which declares a protected Vector "edits" of UndoableEdit objects.
You could get access to that Vector, for listing changes, by writing a class that extends UndoManager and provides public getter metod list getChangesVecor.
Upvotes: 6
Reputation: 3806
If you are after changes in the text of the area you could try one of the following:
Add some form of listener to the JTextArea and each time the text changes store the information as a String in an arrayList, although if you are expecting anything more than a small amount of changes this solution will likely be highly inefficient.
Probably the better option, store the information in a text file/database. This creates a permanent record/log of the information, and could then be read by future programs if required.
Good luck!
Upvotes: 1