code: private WindowListener createFocusListener() {
          return new WindowAdapter() {
              @Override
              public void windowActivated(WindowEvent e) {
                  if (root != null) {
                      root.repaint();
                  }
              }
  
              @Override
              public void windowDeactivated(WindowEvent e) {
                  if (root != null) {
                      root.repaint();
                  }
              }
          };
      }
docs: Creates the focus listener.
  
  @return the focus listener.