UNB/ CS/ David Bremner/ teaching/ java/ UndoTextArea.java
import javax.swing.JTextArea;
public class UndoTextArea extends JTextArea{
    
    LinkedStack undoStack=null;

    public UndoTextArea(int width, int height){
        super(width,height);
        undoStack=new LinkedStack();
    }

    public void setText(String text){
        undoStack.push(getText());
        super.setText(text);
    }

    public void undo(){
        if (undoStack.isEmpty())
            return;
        super.setText((String)undoStack.pop());
    }
}



//