bug found in JComponent

admin

Administrator
Staff member
Hi there:I believe I've discovered a bug with the JComponent class. Icreated a bean that extends JComponent making use of themethod registerKeyboardAction(ActionListener anAction, String aCommand,KeyStroke aKeyStroke, int aCondition).When I made use of my bean in an application the keystokes that Iregistered using this method certainly worked fine, but thentoday I decided to use my bean in an applet. Suddenly the keystokesthat I registered aren't working. I can't figure out why thatis...or how to work around this problem?Here's the function in my bean that gets called when the bean firstbecomes initialized:private void registerKeyStrokes(){if(activeCellEnabled){registerKeyboardAction(new NewAction("MoveLeft"),KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0),WHEN_FOCUSED);registerKeyboardAction(new NewAction("MoveRight"),KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0),WHEN_FOCUSED );registerKeyboardAction(new NewAction("MoveUp"),KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0),WHEN_FOCUSED );registerKeyboardAction(new NewAction("MoveDown"),KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0),WHEN_FOCUSED );registerKeyboardAction(new NewAction("MoveNumPadWest"),KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD4, 0),WHEN_FOCUSED );registerKeyboardAction(new NewAction("MoveNumPadEast"),KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD6, 0),WHEN_FOCUSED );registerKeyboardAction(new NewAction("MoveNumPadNorth"),KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD8, 0),WHEN_FOCUSED );registerKeyboardAction(new NewAction("MoveNumPadSouth"),KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD2, 0),WHEN_FOCUSED );registerKeyboardAction(new NewAction("MoveNumPadNorthWest"),KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD7, 0), WHEN_FOCUSED );registerKeyboardAction(new NewAction("MoveNumPadNorthEast"),KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD9, 0), WHEN_FOCUSED );registerKeyboardAction(new NewAction("MoveNumPadSouthWest"),KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD1, 0), WHEN_FOCUSED );registerKeyboardAction(new NewAction("MoveNumPadSouthEast"),KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD3, 0), WHEN_FOCUSED );registerKeyboardAction(new NewAction("CtrlEnter"),KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,Event.CTRL_MASK), WHEN_FOCUSED );registerKeyboardAction(new NewAction("Control"),KeyStroke.getKeyStroke(KeyEvent.VK_CONTROL,Event.CTRL_MASK), WHEN_FOCUSED );}}Like I said, I don't see anything wrong with it. It certainly works whenused in an application. If you have had similar problem andknow of a workaround, please let me know.Regards,Alan Shiers
 
Back
Top