Solved

Tab order control...

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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 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…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This video teaches viewers about errors in exception handling.
Suggested Courses

752 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