Package 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:
Serializable
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:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetComponentAfter
(Container aContainer, Component aComponent) Gets the next focusable component.getComponentBefore
(Container aContainer, Component aComponent) Gets the previous focusable component.getFirstComponent
(Container aContainer) Gets the first focusable component.getLastComponent
(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
-
Constructor Details
-
CustomFocusTraversalPolicy
Constructor.- Parameters:
all
- The array with the components.
-
-
Method Details
-
getComponentAfter
Gets the next focusable component.- Overrides:
getComponentAfter
in classLayoutFocusTraversalPolicy
- Parameters:
aContainer
- The swing container, e.g. a JFrame.aComponent
- The component to calculate focus.- Returns:
- The next focusable component.
-
getComponentBefore
Gets the previous focusable component.- Overrides:
getComponentBefore
in classLayoutFocusTraversalPolicy
- Parameters:
aContainer
- The swing container, e.g. a JFrame.aComponent
- The component to calculate focus.- Returns:
- The previous focusable component.
-
getFirstComponent
Gets the first focusable component.- Overrides:
getFirstComponent
in classLayoutFocusTraversalPolicy
- Parameters:
aContainer
- The swing container, e.g. a JFrame.- Returns:
- The first focusable component.
-
getLastComponent
Gets the last focusable component.- Overrides:
getLastComponent
in classLayoutFocusTraversalPolicy
- Parameters:
aContainer
- The swing container, e.g. a JFrame.- Returns:
- The last focusable component.
-