Add a helper method to Util - findComponent()

XMLWordPrintable

    • b24
    • generic
    • generic

        Add the following helper method in Util

            private static Component findComponent(final Container container,
                                                   final Predicate<Component> predicate) {
                for (Component child : container.getComponents()) {
                    if (predicate.test(child)) {
                        return child;
                    }
                    if (child instanceof Container cont && cont.getComponentCount() > 0) {
                        Component result = findComponent(cont, predicate);
                        if (result != null) {
                            return result;
                        }
                    }
                }
                return null;
            }

              Assignee:
              Harshitha Onkar
              Reporter:
              Harshitha Onkar
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Created:
                Updated:
                Resolved: