• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

JTextField Tab Order Changing

 
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

setNextFocusableComponent has been deprecated as it overrides the default FocusTraversalPolicy so I would like to avoid using it. However it does get the job done.

The reason I am looking to change the tab order is because the two JTextFields are in a GridLayout but not immediately next to each other. I did some searching and have not found any results.

I do have a KeyListener on these fields and attempted to listen for VK_TAB to then manually set the focus when Tab is pressed, but for some reason the VK_TAB key is not registered as a KeyEvent.

Thanks in advance.
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm reading this that you want to tab only between 2 components (non-adjacent)

If so, something like this maybe

 
Evildoers! Eat my justice! And this tiny ad's justice too!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic