How do I prevent arrow key press in JTextField from scrolling JScrollPane?
I'd like to add a custom arrow key listener for my JTextField . But looks like the arrow keys are bound to the JScrollPane on which I put my text field. How do I unbind them? You could try replacing the key bindings on the scroll pane, but it might make sense to keep them to allow the user to scroll the pane when they are not focused in your text field. Instead, you can add key bindings to the text field that do nothing, which will consume the event and prevent them from begin sent to the scroll pane, for example.... import java.awt.BorderLayout; import java.awt.Dimension; import java.awt