uic.widgets
Class UICFocusTraversalPolicy

java.lang.Object
  extended byjava.awt.FocusTraversalPolicy
      extended byuic.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)
          Returns the Component that should receive the focus when a Window is made visible for the first time.
 Component getLastComponent(Container focusCycleRoot)
          Returns the last Component in the traversal cycle.
 
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.


getComponentBefore

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


getDefaultComponent

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


getFirstComponent

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


getInitialComponent

public Component getInitialComponent(Window window)
Returns the Component that should receive the focus when a Window is made visible for the first time.


getLastComponent

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



Copyright © 2002,2003 Thomas Zander Available under the Free Apache licence