uic.widgets
Class UICFocusTraversalPolicy

java.lang.Object
  extended by java.awt.FocusTraversalPolicy
      extended by uic.widgets.UICFocusTraversalPolicy

public class UICFocusTraversalPolicy
extends FocusTraversalPolicy

A focus traversalPolicy for predefined traversal. The concept of focustraversal means that changing the focus (which widget receives keyboard input) using the TAB key follows a defined order of widgets. This class allows you to set the order to a list where each member is added using the addComponent(Component c) method.

Notice that this class uses a Swing concept introduced in Java version 1.4 which means this class will not compile with older versions of Java.

Common usage:

      myJPanel.setFocusCycleRoot(true);       // if the component is not a normal root
                                              // then we need to do this in order to make sure
                                              // our policy is queried in the first place.
      UICFocusTraversalPolicy policy = new UICFocusTraversalPolicy();
      policy.addComponent(childWidget1);      // first widget to get focus
      policy.addComponent(childWidget2);      // the order in adding equals the order in tabbing.
          // all the other widgets that need to be used in traversal
      myJPanel.setFocusTraversalPolicy(policy);
  

Since:
1.1

Constructor Summary
UICFocusTraversalPolicy()
           
 
Method Summary
 void addComponent(Component c)
           
 Component getComponentAfter(Container focusCycleRoot, Component aComponent)
          Returns the Component that should receive the focus after aComponent.
 Component getComponentBefore(Container focusCycleRoot, Component aComponent)
          Returns the Component that should receive the focus before aComponent.
 Component getDefaultComponent(Container focusCycleRoot)
          Returns the default Component to focus.
 Component getFirstComponent(Container focusCycleRoot)
          Returns the first Component in the traversal cycle.
 Component getInitialComponent(Window window)
           
 Component getLastComponent(Container focusCycleRoot)
          Returns the last Component in the traversal cycle.
 void setInitialComponent(Component c)
          Set the component that will gain focus when a dialog is first shown Only need to set if this component is different from the first component (getFirstComponent)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UICFocusTraversalPolicy

public UICFocusTraversalPolicy()
Method Detail

addComponent

public void addComponent(Component c)

getComponentAfter

public Component getComponentAfter(Container focusCycleRoot,
                                   Component aComponent)
Returns the Component that should receive the focus after aComponent.

Specified by:
getComponentAfter in class FocusTraversalPolicy

getComponentBefore

public Component getComponentBefore(Container focusCycleRoot,
                                    Component aComponent)
Returns the Component that should receive the focus before aComponent.

Specified by:
getComponentBefore in class FocusTraversalPolicy

getDefaultComponent

public Component getDefaultComponent(Container focusCycleRoot)
Returns the default Component to focus.

Specified by:
getDefaultComponent in class FocusTraversalPolicy

getFirstComponent

public Component getFirstComponent(Container focusCycleRoot)
Returns the first Component in the traversal cycle.

Specified by:
getFirstComponent in class FocusTraversalPolicy

setInitialComponent

public void setInitialComponent(Component c)
Set the component that will gain focus when a dialog is first shown Only need to set if this component is different from the first component (getFirstComponent)

Parameters:
c - the component that will gain focus when its parent window is shown
See Also:
getInitialComponent(java.awt.Window)

getInitialComponent

public Component getInitialComponent(Window window)
Overrides:
getInitialComponent in class FocusTraversalPolicy

getLastComponent

public Component getLastComponent(Container focusCycleRoot)
Returns the last Component in the traversal cycle.

Specified by:
getLastComponent in class FocusTraversalPolicy


Copyright © 2002-2004 Thomas Zander Available under the Free Apache licence