need help with actionmap and inputmap for jdialog

hi, I want to do the same as this thread:

http://forum.java.sun.com/thread.jspa?threadID=446614&messageID=2026106

But nothing happens when I press my left and right buttons in the Jdialog. I'm not sure what is wrong with my code. Any help appreciated!

This is in the constructor of the JDialog:

this.setFocusable(true);

ActionMap am = getRootPane().getActionMap();

InputMap im = getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

Object windowLeftKey =new Object();

Object windowRightKey =new Object();

KeyStroke windowLeftStroke = KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0);

KeyStroke windowRightStroke = KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0);

Action windowLeftAction =new AbstractAction(){

publicvoid actionPerformed(ActionEvent e){

setAlphaWinner();

}

};

Action windowRightAction =new AbstractAction(){

publicvoid actionPerformed(ActionEvent e){

setBetaWinner();

}

};

am.put(windowLeftKey, windowLeftAction);

im.put(windowLeftStroke, windowLeftKey);

am.put(windowRightKey, windowRightAction);

im.put(windowRightStroke, windowRightKey);

[1741 byte] By [Tjorriemorriea] at [2007-11-27 9:41:38]
# 1

You could try using:

JComponent.WHEN_IN_FOCUSED_WINDOW

If you need further help then you need to create a "Short, Self Contained, Compilable and Executable, Example Program (SSCCE)",

see http://homepage1.nifty.com/algafield/sscce.html,

that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.

camickra at 2007-7-12 23:20:56 > top of Java-index,Desktop,Core GUI APIs...