Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8353755

Add a helper method to Util - findComponent()

XMLWordPrintable

    • Fix Understood
    • 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;
          }

            honkar Harshitha Onkar
            honkar Harshitha Onkar
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: