gr.zeus.ui.typesafe

## Class CustomFocusTraversalPolicy

- java.lang.Object
- - java.awt.FocusTraversalPolicy
  - - javax.swing.InternalFrameFocusTraversalPolicy
    - - javax.swing.SortingFocusTraversalPolicy
      - - javax.swing.LayoutFocusTraversalPolicy
        - - gr.zeus.ui.typesafe.CustomFocusTraversalPolicy

- All Implemented Interfaces:
    java.io.Serializable

      public final class CustomFocusTraversalPolicy
      extends javax.swing.LayoutFocusTraversalPolicy

  This class creates a custom focus policy for Swing components by extending LayoutFocusTraversalPolicy. The focus policy is based upon an array of components. These components are focused as they are placed in the array: array[0] --> array[1] --> ... ---> array[last] ---> array[0] Only components in the array are focused, all other components only gain focus if you place the mouse pointer inside. This is a pretty clean and solid solution to the Swing Focus Issue, at least until Sun provides us with a better one.

  Since:
    1.20
  Author:
    Gregory Kotsaftis
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `CustomFocusTraversalPolicy(java.awt.Component[] all)` Constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.awt.Component` | `getComponentAfter(java.awt.Container aContainer, java.awt.Component aComponent)` Gets the next focusable component.
    `java.awt.Component` | `getComponentBefore(java.awt.Container aContainer, java.awt.Component aComponent)` Gets the previous focusable component.
    `java.awt.Component` | `getFirstComponent(java.awt.Container aContainer)` Gets the first focusable component.
    `java.awt.Component` | `getLastComponent(java.awt.Container aContainer)` Gets the last focusable component.

    - ### Methods inherited from class javax.swing.LayoutFocusTraversalPolicy

      `accept`

    - ### Methods inherited from class javax.swing.SortingFocusTraversalPolicy

      `getComparator, getDefaultComponent, getImplicitDownCycleTraversal, setComparator, setImplicitDownCycleTraversal`

    - ### Methods inherited from class javax.swing.InternalFrameFocusTraversalPolicy

      `getInitialComponent`

    - ### 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

    - #### CustomFocusTraversalPolicy

          public CustomFocusTraversalPolicy(java.awt.Component[] all)

      Constructor.

      Parameters:
        `all` - The array with the components.

  - ### Method Detail

    - #### getComponentAfter

          public java.awt.Component getComponentAfter(java.awt.Container aContainer,
                                                      java.awt.Component aComponent)

      Gets the next focusable component.

      Overrides:
        `getComponentAfter` in class `javax.swing.LayoutFocusTraversalPolicy`
      Parameters:
        `aContainer` - The swing container, e.g. a JFrame.
        `aComponent` - The component to calculate focus.

      Returns:
        The next focusable component.

    - #### getComponentBefore

          public java.awt.Component getComponentBefore(java.awt.Container aContainer,
                                                       java.awt.Component aComponent)

      Gets the previous focusable component.

      Overrides:
        `getComponentBefore` in class `javax.swing.LayoutFocusTraversalPolicy`
      Parameters:
        `aContainer` - The swing container, e.g. a JFrame.
        `aComponent` - The component to calculate focus.

      Returns:
        The previous focusable component.

    - #### getFirstComponent

          public java.awt.Component getFirstComponent(java.awt.Container aContainer)

      Gets the first focusable component.

      Overrides:
        `getFirstComponent` in class `javax.swing.LayoutFocusTraversalPolicy`
      Parameters:
        `aContainer` - The swing container, e.g. a JFrame.

      Returns:
        The first focusable component.

    - #### getLastComponent

          public java.awt.Component getLastComponent(java.awt.Container aContainer)

      Gets the last focusable component.

      Overrides:
        `getLastComponent` in class `javax.swing.LayoutFocusTraversalPolicy`
      Parameters:
        `aContainer` - The swing container, e.g. a JFrame.

      Returns:
        The last focusable component.