tags:

views:

117

answers:

3

I am making a text editor using Java swing. I am using JTextArea for the same. I want to know how I can use Undo and Redo functionality in JTextArea as I am not able to use it.

+3  A: 

Its been a while since I did this and I dont recall the details, but here is a link with some info: http://java.sun.com/docs/books/tutorial/uiswing/components/generaltext.html

Scroll down to the section titled "Listening for Changes on a Document" to get started.

Marshall Alsup
+1, who is the person that downvoted this?? The tutorial has a working example and explains what is going on, which most certainly answers the question. Now it is up to the OP to read the tutorial, in fact the OP should have read the tutorial first before posting this question. In fact, if the user wasn't aware of the Swing tutorial before they know have access to a valuable reference that can help on future questions. This is the way all questions should be answered.
camickr
Thanks for your kind words :)
Marshall Alsup
Thanks for ur sarcastic remarks camickr.Thank for helping Marshall.
Logan
+1  A: 

You will have to implement your own undo / redo functionality.

Dev er dev
The Document underlying a JTextArea has undo functionality.
DJClayworth
+4  A: 

As I understand it, JTextArea has no inherent Undo/Redo functionality built in, but a Google search did find this article which might be helpful.

There apparently exists an Undo Manager in javax.swing which you can hook up to the JTextArea's change events.

TeeBasins
Here is a link with a more complete example: http://www.java-forums.org/javax-swing/9570-undo-redo-jtextarea.html
Petar Minchev
Thanks Peter. I got my problem solved.
Logan