code: private static WindowListener createWeakWindowFocusListener(WindowFocusListener windowFocusListener) {
          final WeakReference<WindowFocusListener> weakReference = new WeakReference<WindowFocusListener>(windowFocusListener);
  
          return new WindowAdapter() {
              public void windowActivated(WindowEvent e) {
                  // TODO if the WeakReference's object is null, remove the
                  // WeakReference as a FocusListener.
                  if (weakReference.get() != null) {
                      weakReference.get().windowGainedFocus(e);
                  }
              }
  
              public void windowDeactivated(WindowEvent e) {
                  if (weakReference.get() != null) {
                      weakReference.get().windowLostFocus(e);
                  }
              }
          };
      }
docs: Create the weak window focus listener.
  
  @param  windowFocusListener the focus listener
  
  @return the weak referenced listener.