?
Solved

Tab order control...

Posted on 1998-05-26
4
Medium Priority
?
216 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 100 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

719 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