FileDocCategorySizeDatePackage
UndoStyleFrame.javaAPI DocExample2683Thu Oct 24 20:14:26 BST 2002None

UndoStyleFrame

public class UndoStyleFrame extends StyleFrame

Fields Summary
protected UndoAct
undoAction
protected RedoAct
redoAction
Constructors Summary
public UndoStyleFrame()

 // 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);
  
Methods Summary
public static voidmain(java.lang.String[] args)

    JFrame frame = new UndoStyleFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(400, 300);
    frame.setVisible(true);