File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes NextFocusableComponent -> FocusTraversalPolicy Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "NextFocusableComponent -> FocusTraversalPolicy" Watch "NextFocusableComponent -> FocusTraversalPolicy" New topic
Author

NextFocusableComponent -> FocusTraversalPolicy

Carlos Delgado
Greenhorn

Joined: Aug 17, 2004
Posts: 15
Hi all again!
I'm using a Swing application and I noticed that "NextFocusableComponent" is being deprecated and replaced by the "FocusTraversalPolicy".
Does anyone here know how does it work?? All I want is set an order for my controls when the TAB key is pressed.
Thanks!!
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
A bit of 'light' reading

http://java.sun.com/j2se/1.4/docs/api/java/awt/doc-files/FocusSpec.html
Carlos Delgado
Greenhorn

Joined: Aug 17, 2004
Posts: 15
Thanks for your reply!
But in the Sun Java help pages there are not examples of it... :'( I was trying to avoid those eternal readings without examples.
All I want is a little sample for changing focus between 3 JTextFields! Any ideas?
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
Here's something to play around with - it just reverses the 'normal' tab
order i.e. bottom to top, but you can make it anything you want, in keyPressed()

Don't know if this is a 'reasonable' way to do it, or if there's any pitfalls doing it this way, so lots of testing required.

Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
It seems the correct is something like this

Carlos Delgado
Greenhorn

Joined: Aug 17, 2004
Posts: 15
Thanks, Michael! I got it working now!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NextFocusableComponent -> FocusTraversalPolicy