Netbeans JApplet: Adding a working redo button to redo a change when adding elements to a stack

100 views Asked by At

My goal here is to code a redo button for a JApplet that pushes and pops elements from a stack on a ContentTextArea. I have successfully coded the undo button, but am having troubles with the redo button. Has anyone here done this before?

private void undoButtonActionPerformed(java.awt.event.ActionEvent evt) {                                           
    try {
        undoManager.undo();
        logTextArea.append("Undo Unfinished\n");
        ContentTextArea.setText(myStack.toString());
        ContentTextArea.setCaretPosition(0);
        inputTextField.setText(null);
        inputTextField.requestFocus();
    } catch(CannotUndoException cue) {
        logTextArea.append("Cannot Undo.\n");
    }                                          
}

Here is the redo button that I am trying to code. I don't believe it is coded exactly like the undo button, so I am having trouble implementing it to my JApplet.

private void redoButtonActionPerformed(java.awt.event.ActionEvent evt) {                                           
    try {
        redoManager.redo();
        logTextArea.append("Redo Unfinished\n");
        ContentTextArea.setText(myStack.toString());
        ContentTextArea.setCaretPosition(0);
        inputTextField.setText(null);
        inputTextField.requestFocus();
    } catch(CannotUndoException cue) {
        logTextArea.append("Cannot Redo.\n");
    }
}

private UndoManager undoManager=new UndoManager();
0

There are 0 answers