code: protected boolean activateAndFocusComponentWindow(Component c) {
          Component parent = c;
          //active the parent window
          while (!(parent instanceof Window)) {
              parent = parent.getParent();
          }
          final Window window = (Window) parent;
  
          if (!window.isFocused()) {
              if (!window.isVisible()) {
                  LOGGER.trace("cannot activate and focus the window of '" + c.getName() + "' cause its window is not visible");
                  return false;
              }
              LOGGER.trace("try to activate and focus the window of '" + c.getName() + "' cause its window is not focused");
              final KeyboardFocusManager keyboardFocusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
              WindowFocusedListener windowFocusedListener = new WindowFocusedListener(window);
              window.addWindowFocusListener(windowFocusedListener);
              SwingUtilities.invokeLater(() -> {
                  // try to activate application if not active
                  if (keyboardFocusManager.getActiveWindow() == null) {
                      LOGGER.trace("try to activate application");
                      // create and display a new frame to force application activation
                      JFrame newFrame = new JFrame();
                      newFrame.pack();
                      newFrame.setVisible(true);
                      newFrame.toFront();
                      newFrame.setVisible(false);
                      newFrame.dispose();
                  }
  
                  window.toFront();
  
                  LOGGER.trace("current focused window : " + keyboardFocusManager.getFocusedWindow());
                  window.requestFocus();
              });
  
              boolean windowFocused = windowFocusedListener.waitUntilWindowFocused();
              window.removeWindowFocusListener(windowFocusedListener);
              LOGGER.trace("window focused ? " + windowFocused);
              LOGGER.trace("focused window after request: " + keyboardFocusManager.getFocusedWindow());
              if (!windowFocused) {
                  LOGGER.warn("The window activation/focus process failed!!!");
                  return false;
              }
              LOGGER.trace("The window activation/focus process is completed!!!");
          } else {
              LOGGER.trace("the window of '" + c.getName() + "' is already focused");
          }
          return true;
      }
docs: Try to activate and focus the window containing the component.
  
  @param c the component contained in the window to active.
  @return <code>true</code> only if the parent window is active at the end of the activation process.