code: private static WindowFocusListener createRepaintWindowListener(final JComponent component) {
          return new WindowAdapter() {
              public void windowActivated(WindowEvent e) {
                  component.repaint();
              }
  
              public void windowDeactivated(WindowEvent e) {
                  component.repaint();
              }
          };
      }
docs: Create the repaint window listener.
  
  @param  component the component.
  
  @return the listener.