La unica forma que lo hice hacer funcionar es de esta manera no haciendolo dentro del ciclo for
Código PHP:
KeyStroke cero = KeyStroke.getKeyStroke('0');
map=arr[0].getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
map.put(cero,"action");
ActionMap actionmap=arr[0].getActionMap();
actionmap.put("action",actionListener);
KeyStroke one = KeyStroke.getKeyStroke('1');
map=arr[1].getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
map.put(one,"action");
ActionMap actuno=arr[1].getActionMap();
actuno.put("action",actionListener);
KeyStroke two= KeyStroke.getKeyStroke('2');
map=arr[2].getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
map.put(two,"action");
ActionMap acttwo=arr[2].getActionMap();
acttwo.put("action",actionListener);
KeyStroke three= KeyStroke.getKeyStroke('3');
map=arr[3].getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
map.put(three,"action");
ActionMap actthree=arr[3].getActionMap();
actthree.put("action",actionListener);
KeyStroke four= KeyStroke.getKeyStroke('4');
map=arr[4].getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
map.put(four,"action");
ActionMap actfour=arr[4].getActionMap();
actfour.put("action",actionListener);
KeyStroke five= KeyStroke.getKeyStroke('5');
map=arr[5].getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
map.put(five,"action");
ActionMap actfive=arr[5].getActionMap();
actfive.put("action",actionListener);
KeyStroke six= KeyStroke.getKeyStroke('6'); //KeyEvent.VK_NUMPAD6,0
map=arr[6].getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
map.put(six,"action");
ActionMap actsix=arr[6].getActionMap();
actsix.put("action",actionListener);
KeyStroke seven= KeyStroke.getKeyStroke('7');
map=arr[7].getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
map.put(seven,"action");
ActionMap actseven=arr[7].getActionMap();
actseven.put("action",actionListener);
KeyStroke eight= KeyStroke.getKeyStroke('8');
map=arr[8].getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
map.put(eight,"action");
ActionMap acteight=arr[8].getActionMap();
acteight.put("action",actionListener);
KeyStroke nine= KeyStroke.getKeyStroke('9');
map=arr[9].getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
map.put(nine,"action");
ActionMap actnine=arr[9].getActionMap();
actnine.put("action",actionListener);
La razon es :
By sharing an InputMap or ActionMap, any change to the shared InputMap or ActionMap will affect all components sharing the InputMap or ActionMap. WHEN_FOCUSED and WHEN_ANCESTOR_OF_FOCUSED_COMPONENT types of InputMaps can be shared.
WHEN_IN_FOCUSED_WINDOW InputMaps cannot be shared.
Espero ha alguien le sirva