code: public static void installJComponentRepainterOnWindowFocusChanged(JComponent component) {
          // TODO check to see if the component already has an ancestor.
          WindowListener   windowListener   = createWeakWindowFocusListener(createRepaintWindowListener(component));
          AncestorListener ancestorListener = createAncestorListener(component, windowListener);
  
          component.addAncestorListener(ancestorListener);
      }
docs: Installs a listener on the given {@link JComponent}'s parent
  {@link Window} that repaints the given component when the parent window's
  focused state changes. If the given component does not have a parent at
  the time this method is called, then an ancestor listener will be
  installed that installs a window listener when the components parent
  changes.
  
  @param component the {@code JComponent} to add the repaint focus listener
  to.