// an Action for redo
super();
setTitle("UndoStyleFrame");
// register the Actions as undo listeners (we inherited textPane)
textPane.getDocument().addUndoableEditListener(undoAction);
textPane.getDocument().addUndoableEditListener(redoAction);
// create menu for undo/redo
JMenu editMenu = new JMenu("Edit");
editMenu.add(new JMenuItem(undoAction));
editMenu.add(new JMenuItem(redoAction));
menuBar.add(editMenu); // we inherited menuBar from superclass
// create buttons for undo/redo
JPanel buttonPanel = new JPanel();
buttonPanel.add(new JButton(undoAction));
buttonPanel.add(new JButton(redoAction));
getContentPane().add(buttonPanel, java.awt.BorderLayout.SOUTH);