Disabling F4 key for comboboxes - TechRepublic
General discussion
May 16, 2002 at 10:03 PM
shepps

Disabling F4 key for comboboxes

by shepps . Updated 24 years, 1 month ago

I have the following problem. I have programmed a dialog where one of the buttons is registered to react to the F4 key being pressed. This works, no problem. Only if I am in a Combobox and press F4, the Combobox opens which is not desired. The F4 button DOES still get pressed too, but I would like to suppress the combobox opening its list.

Does anyone have any ideas? Just in case you are wondering how I registered the F4 key, here is how:

KeyStroke F4Key = KeyStroke.getKeyStroke( KeyEvent.VK_F4, 0 );
String F4actiontext = “F4_ACTION”;
InputMap panel_im = getInputMap( JComponent.WHEN_IN_FOCUSED_WINDOW );
panel_im.put( F4Key, F4actiontext );
ActionMap panel_am = getActionMap();
panel_am.put( F4actiontext, new KeyActionListener(F4actiontext) );

This discussion is locked

All Comments