diff options
Diffstat (limited to 'src/nativewindow/classes')
-rw-r--r-- | src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java index 66be82a44..f38e7ea2b 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java +++ b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java @@ -69,6 +69,33 @@ public class AWTMisc { return (Container) c; } + public static interface ComponentAction { + /** + * @param c the component to perform the action on + */ + public void run(Component c); + } + + public static int performAction(Container c, Class<?> cType, ComponentAction action) { + int count = 0; + final int cc = c.getComponentCount(); + for(int i=0; i<cc; i++) { + final Component e = c.getComponent(i); + if( e instanceof Container ) { + count += performAction((Container)e, cType, action); + } else if( cType.isInstance(e) ) { + action.run(e); + count++; + } + } + // we come at last .. + if( cType.isInstance(c) ) { + action.run(c); + count++; + } + return count; + } + /** * Traverse to the next forward or backward component using the * container's FocusTraversalPolicy. |