Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JTextField Tab Order Changing  RSS feed

 
Jeff Grant
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • 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.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • 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

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!