Solved

Tab order control...

Posted on 1998-05-26
4
210 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

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Apps blocked by Java 9 81
fibonacci ten numbers 4 39
hibernate example using maven 12 42
jsp login check 12 32
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

809 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