I have attached events to certain keystrokes in order to allow a user to consult a list of images viewable in a JScrollPane within a JFrame. Left and right arrow keys allow the user to go forward or backward through the list of images. Up and down arrow keys allow the image to be blown up or reduced in size. Several other keystrokes have events attached to that should only affect the images. I recently added a JList, containing the 26 letters of the alphabet, to the NORTH region of the JFrame, and this component seems to want to steal the show with regards to keybinding. Now when it has the focus, and it usually does, and an upward or downward arrow key is used, a new letter in the JList is selected. Keybinding for the JScrollPane no longer works unless focus on the JList is lost. Only if the TAB key is first pressed does keybinding as programmed fall back to the JScrollPane inside the JFrame.
I want to be able to permanently disable the default keybinding for the JList, so if ever it has focus no keystrokes can affect its behaviour.
Only if the TAB key is first pressed does keybinding as programmed fall back to the JScrollPane inside the JFrame.
Yes, KeyStrokes are first handle by the component with focus. You need to understand how the (3) different types of InputMaps work. Key Bindings explains some of the basics and contains a link to the Swing tutorial which explains bindings in more detail.