Solved

Tab order control...

Posted on 1998-05-26
4
212 Views
Last Modified: 2010-04-16
I have a panel which contains textfields and choice list components.  The default tab order is whatever order that the components are added, but I want to change that.  What is the best way to override the default tab ordering and create your own tab ordering?
0
Comment
Question by:stepma
4 Comments
 
LVL 2

Expert Comment

by:aziz061097
ID: 1221486
The order of add statements defines the Tab order. Just change the order of the add statements . If you want the display in a particular format use some layout manager to place the componenents as you want but the add statements must be in the order of your tab sequence
0
 
LVL 1

Expert Comment

by:froderik
ID: 1221487
Another way to do it that I haven't tried but just came to think about is to catch KeyEvents for the Panel and use setFocus() method calls to control the order it the key pressed is tab.
0
 
LVL 1

Accepted Solution

by:
dufort earned 50 total points
ID: 1221488
Basically, there are two ways of managing focus on your forms.

FIRST: write a FocusListener class, which will respond to the FocusEvent event with the methods focusGained() and focusLost(). See the Java tutorial for more details at:
http://java.sun.com/docs/books/tutorial/ui/components/focuslistener.html
(NOTE: I don't know if you have to register to the Java Developers Connection to access this page. Anyway, registering is free.)

SECOND: if your are using JFC components, look at the meyhods setNextFocusableComponent() and so on, in com.sun.java.swing.JComponent. For standard AWT components, use the requestFocus() method on the next component to set focus. How to know when to set focus? Implement interface FocusListener on your form.

Hope it helped!

0
 
LVL 4

Expert Comment

by:evijay
ID: 1221489
You can seperate focus traversal into a focusmanager class to which you will give a list of components. To change focus traversal order, pass the same list again in a different order. The focusmanager implements focus listener interface and traverses the focus using requestFocus if the registered listeners on focus traversal agree for that.

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question