i can't seem to get this example to work. the goal is for "REDO" to be printed when you type ctrl+y, and "UNDO" when you type ctrl+z. there are no errors, but nothing is outputted when you type ctrl+y or ctrl+z.
import java.awt.event.*; import javax.swing.*; public class Test extends JPanel{ public Test(){ setFocusable(true); ActionMap a = getActionMap(); InputMap i = getInputMap(); KeyStroke undoKeyStroke = KeyStroke.getKeyStroke("control typed z"); KeyStroke redoKeyStroke = KeyStroke.getKeyStroke("control typed y"); i.put(undoKeyStroke, "undo"); i.put(redoKeyStroke, "redo"); a.put("undo",undoAction); a.put("redo",redoAction); } public static void main(String[] args){ JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(300,300); frame.getContentPane().add(new Test()); frame.setVisible(true); } Action redoAction = new AbstractAction(){ public void actionPerformed(ActionEvent e){ System.out.println("REDO"); } }; Action undoAction = new AbstractAction(){ public void actionPerformed(ActionEvent e){ System.out.println("UNDO"); } }; }