Detecting Tab Key Pressed Event in JTextField ‘s // Event.VK_TAB KeyPressed 3

Adding a KeyListener to a JTextField to detect KeyPressed events is pretty straightforward. Buy maybe you have encountered some problems when trying to detect special key such as TAB’s. This issue is due to LowLevel keyEvents captured by Swing’s default FocusTraversalKeys. What we need to do to capture the VK_TAB KeyEvent is to remove the default FocusTraversalKeys from the component.

Once we’ve done this with the component, the tab KeyEvent will not be captured by swing’s default focus traversal keys and we will be able to add events normally.

Tweet about this on TwitterShare on FacebookShare on LinkedInShare on Google+Pin on PinterestEmail this to someone

Leave a comment

Your email address will not be published. Required fields are marked *

3 thoughts on “Detecting Tab Key Pressed Event in JTextField ‘s // Event.VK_TAB KeyPressed

  • Thao

    Can you release a jar-source file feaorch version of jfxrt library (ideally on maven central repo) ?It could be useful for those who work with an integrated build toolkit like maven which can download automatically source and javadcoc by version.Because working with an open source APi without source code is painful.Thx