summaryrefslogtreecommitdiffstats
path: root/src/nativewindow/classes
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-06-24 06:50:40 +0200
committerSven Gothel <[email protected]>2013-06-24 06:50:40 +0200
commit62f9525a9caba51fc4484c2ab47d64b516dc9d43 (patch)
tree74c92348b6ded6760f9f39a3fdbf14350a7eb727 /src/nativewindow/classes
parent85f4b824dcf1ff6ebb658ffd242eea2f9d8cd087 (diff)
Refine cb7118fc875b6722803e4b11d5681671962a8d3a: Unify get next/prev focus component method.
Diffstat (limited to 'src/nativewindow/classes')
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java31
1 files changed, 10 insertions, 21 deletions
diff --git a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java
index 2524f107a..66be82a44 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java
@@ -69,7 +69,15 @@ public class AWTMisc {
return (Container) c;
}
- public static Component getNextFocus(Component comp) {
+ /**
+ * Traverse to the next forward or backward component using the
+ * container's FocusTraversalPolicy.
+ *
+ * @param comp the assumed current focuse component
+ * @param forward if true, returns the next focus component, otherwise the previous one.
+ * @return
+ */
+ public static Component getNextFocus(Component comp, boolean forward) {
Container focusContainer = comp.getFocusCycleRootAncestor();
while ( focusContainer != null &&
( !focusContainer.isShowing() || !focusContainer.isFocusable() || !focusContainer.isEnabled() ) )
@@ -80,7 +88,7 @@ public class AWTMisc {
Component next = null;
if (focusContainer != null) {
final FocusTraversalPolicy policy = focusContainer.getFocusTraversalPolicy();
- next = policy.getComponentAfter(focusContainer, comp);
+ next = forward ? policy.getComponentAfter(focusContainer, comp) : policy.getComponentBefore(focusContainer, comp);
if (next == null) {
next = policy.getDefaultComponent(focusContainer);
}
@@ -88,25 +96,6 @@ public class AWTMisc {
return next;
}
- public static Component getPrevFocus(Component comp) {
- Container focusContainer = comp.getFocusCycleRootAncestor();
- while ( focusContainer != null &&
- ( !focusContainer.isShowing() || !focusContainer.isFocusable() || !focusContainer.isEnabled() ) )
- {
- comp = focusContainer;
- focusContainer = comp.getFocusCycleRootAncestor();
- }
- Component prev = null;
- if (focusContainer != null) {
- final FocusTraversalPolicy policy = focusContainer.getFocusTraversalPolicy();
- prev = policy.getComponentBefore(focusContainer, comp);
- if (prev == null) {
- prev = policy.getDefaultComponent(focusContainer);
- }
- }
- return prev;
- }
-
/**
* Issue this when your non AWT toolkit gains focus to clear AWT menu path
*/