title: registerKeyboardAction with VK_SPACE not working
body: <p>Background: I have a table cell editor that when invoked pops up a dialog with a list of checkboxes, and 2 buttons (OK and Cancel).  All works well.  I later registered keyboard actions so that the ENTER and ESCAPE keys would perform the ok/cancel actions.  Still no problems.</p>
  
  <p>Using the same technique, I tried to register the SPACE key to do a third action. This didn't fire.  Sample code:</p>
  
  <pre><code>import java.awt.*;
  import java.awt.event.*;
  
  import javax.swing.*;
  
  public class DialogTest implements Runnable
  {
    JDialog dialog;
    JList jlist;
  
    public static void main(String[] args)
    {
      SwingUtilities.invokeLater(new DialogTest());
    }
  
    public void run()
    {    
      ActionListener okListener = new ActionListener()
      {
        public void actionPerformed(ActionEvent e)
        {
          close(true);
        }
      };
  
      ActionListener cancelListener = new ActionListener()
      {
        public void actionPerformed(ActionEvent e)
        {
          close(false);
        }
      };
  
      ActionListener otherListener = new ActionListener()
      {
        public void actionPerformed(ActionEvent e)
        {
          doOther();
        }
      };
  
      JButton okButton = new JButton("OK");
      okButton.addActionListener(okListener);
  
      JButton cancelButton = new JButton("Cancel");
      cancelButton.addActionListener(cancelListener);
  
      jlist = new JList(new String[]{"A", "B", "C", "D", "E", "F", "G"});
      jlist.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
      jlist.setVisibleRowCount(5);
  
      JScrollPane scroll = new JScrollPane(jlist);
      scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
  
      JPanel buttonsPanel = new JPanel(new FlowLayout());
      buttonsPanel.add(okButton);
      buttonsPanel.add(cancelButton);
  
      JPanel content = new JPanel(new BorderLayout());
      content.add(scroll, BorderLayout.CENTER);
      content.add(buttonsPanel, BorderLayout.SOUTH);
  
      dialog = new JDialog((Frame) null, true);
      dialog.setContentPane(content);
      dialog.pack();
      dialog.setLocationRelativeTo(null);
  
      dialog.getRootPane().registerKeyboardAction(okListener,
          KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0),
          JComponent.WHEN_IN_FOCUSED_WINDOW);
  
      dialog.getRootPane().registerKeyboardAction(cancelListener,
          KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
          JComponent.WHEN_IN_FOCUSED_WINDOW);
  
      // This doesn't work
      dialog.getRootPane().registerKeyboardAction(otherListener,
          KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0),
          JComponent.WHEN_IN_FOCUSED_WINDOW);
  
      dialog.setVisible(true);
    }
  
    private void close(boolean commit)
    {
      if (commit)
      {
        System.out.println("Now saving...");
      }
      else
      {
        System.out.println("Now closing...");
        System.exit(0);
      }
    }
  
    private void doOther()
    {
      System.out.println("current selection: " + jlist.getSelectedValue());
    }
  }
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>Thanks to mKorbel's suggestion (and useful link!), I got this to work:</p>
  
  <p>1) Change the line <code>ActionListener otherListener = new ActionListener(){...}</code> to:</p>
  
  <pre><code>Action otherListener = new AbstractAction(){...}
  </code></pre>
  
  <p>2) Change the SPACE keystroke registration to:</p>
  
  <pre><code>KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0);
  Object key = keyStroke.toString();
  jlist.getInputMap().put(keyStroke, key);
  jlist.getActionMap().put(key, otherAction);
  </code></pre>
  
  <p>Note that the registration is for the JList, not the JDialog as the other 2 keystrokes are.</p>