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

    public JUndoTextField(int width){
        super(width);
        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());
    }
}



//