com.retek.commons.gui.util
Class RetekFocusPolicy

java.lang.Object
  extended byjava.awt.FocusTraversalPolicy
      extended bycom.retek.commons.gui.util.RetekFocusPolicy

public class RetekFocusPolicy
extends java.awt.FocusTraversalPolicy

This class is the keyboard focus traversal policy for all applications. Any method of the FocusTraversalPolicy that does not supply a component with its own code will then try to use LayoutFocusTraversalPolicy to find the component. The default order of components in a container is determined by getComponents() unless the container is a RPanel, then it uses getFocusCycleComponents().


Constructor Summary
RetekFocusPolicy()
          Creates a new RetekFocusPolicy.
 
Method Summary
protected  boolean accept(java.awt.Component component)
          Accepts or rejects a component.
protected  void addComponentToArray(java.awt.Component component)
          Adds a component to the global component array.
protected  void buildFullCycle(java.awt.Container container, java.awt.Component component)
          Builds a full cycle of components for the container, attempting to set the global index of the component passed in.
 java.awt.Component getComponentAfter(java.awt.Container focusCycleRoot, java.awt.Component component)
          Returns the Component that should receive the focus after component.
 java.awt.Component getComponentBefore(java.awt.Container focusCycleRoot, java.awt.Component component)
          Returns the Component that should receive the focus before component.
 java.awt.Component getDefaultComponent(java.awt.Container focusCycleRoot)
          Returns the default Component to focus.
 java.awt.Component getFirstComponent(java.awt.Container focusCycleRoot)
          Returns the first Component in the traversal cycle.
 java.awt.Component getLastComponent(java.awt.Container focusCycleRoot)
          Returns the last Component in the traversal cycle.
protected  void processCycleComponent(java.awt.Component component)
          Processes a component to determine if it should be added to the global cycle array.
 
Methods inherited from class java.awt.FocusTraversalPolicy
getInitialComponent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RetekFocusPolicy

public RetekFocusPolicy()
Creates a new RetekFocusPolicy.

Method Detail

getDefaultComponent

public java.awt.Component getDefaultComponent(java.awt.Container focusCycleRoot)
Returns the default Component to focus. This Component will be the first to receive focus when traversing down into a new focus traversal cycle rooted at focusCycleRoot.

NOTE: This method should be altered to scan the components in the buildFullCycle() method and return a "default" component such as a default button if one is found.

Parameters:
focusCycleRoot - The focus cycle root whose default Component is to be returned
Returns:
The default Component in the traversal cycle when focusCycleRoot is the focus cycle root, or null if no suitable Component can be found.
Throws:
java.lang.IllegalArgumentException - If focusCycleRoot is null.

getFirstComponent

public java.awt.Component getFirstComponent(java.awt.Container focusCycleRoot)
Returns the first Component in the traversal cycle. This method is used to determine the next Component to focus when traversal wraps in the forward direction.

Parameters:
focusCycleRoot - The focus cycle root whose first Component is to be returned.
Returns:
The first Component in the traversal cycle when focusCycleRoot is the focus cycle root, or null if no suitable Component can be found.
Throws:
java.lang.IllegalArgumentException - If focusCycleRoot is null.

getLastComponent

public java.awt.Component getLastComponent(java.awt.Container focusCycleRoot)
Returns the last Component in the traversal cycle. This method is used to determine the next Component to focus when traversal wraps in the reverse direction.

Parameters:
focusCycleRoot - The focus cycle root whose last Component is to be returned.
Returns:
The last Component in the traversal cycle when focusCycleRoot is the focus cycle root, or null if no suitable Component can be found.
Throws:
java.lang.IllegalArgumentException - If focusCycleRoot is null

getComponentAfter

public java.awt.Component getComponentAfter(java.awt.Container focusCycleRoot,
                                            java.awt.Component component)
Returns the Component that should receive the focus after component. focusCycleRoot must be a focus cycle root of component.

Parameters:
focusCycleRoot - A focus cycle root of component.
component - A (possibly indirect) child of focusCycleRoot, or focusCycleRoot itself.
Returns:
The Component that should receive the focus after aComponent, or null if no suitable Component can be found.
Throws:
java.lang.IllegalArgumentException - If focusCycleRoot is not a focus cycle root of component, or if either focusCycleRoot or component is null.

getComponentBefore

public java.awt.Component getComponentBefore(java.awt.Container focusCycleRoot,
                                             java.awt.Component component)
Returns the Component that should receive the focus before component. focusCycleRoot must be a focus cycle root of component.

Parameters:
focusCycleRoot - A focus cycle root of component.
component - A (possibly indirect) child of focusCycleRoot, or focusCycleRoot itself.
Returns:
The Component that should receive the focus before component, or null if no suitable Component can be found.
Throws:
java.lang.IllegalArgumentException - If focusCycleRoot is not a focus cycle root of component, or if either focusCycleRoot or component is null.

buildFullCycle

protected void buildFullCycle(java.awt.Container container,
                              java.awt.Component component)
Builds a full cycle of components for the container, attempting to set the global index of the component passed in.

Parameters:
container - A container to build the global focus cycle for.
component - A component to find in the cycle and set the global index.`

processCycleComponent

protected void processCycleComponent(java.awt.Component component)
Processes a component to determine if it should be added to the global cycle array. JComboBox and JTable are automatically added to the global array. JScrollPane has its view added to the global array. RPanels have their focus cycle components processed. Containers have their components processed. The container's getComponents() method sorts the components in the order they are added to the container.

Parameters:
component - The component to process.

addComponentToArray

protected void addComponentToArray(java.awt.Component component)
Adds a component to the global component array. It only adds the component if it passes the accept() test. If the component matches the matchcomp [global match component] the global index is set. This speeds up the after() and before() methods.

Parameters:
component - The component to add.

accept

protected boolean accept(java.awt.Component component)
Accepts or rejects a component. A component is rejected if it is null, not showing, not visible, not displayable, not focusable or not enabled.

Parameters:
component - The component to validate.

Returns:
True if the component can receive focus, false if not.


Copyright © 2004 Retek Inc. All Rights Reserved. - Generated at Fri, 10/22/2004 07:28