private void dispose() {

    Runnable runnable = () -> {
      myFrame.dispose();

      Toolkit.getDefaultToolkit().removeAWTEventListener(myMulticastListener);
      myKeyboardFocusManager.removeKeyEventDispatcher(myKeyEventDispatcher);

      myTargetComponent.removeComponentListener(myComponentListener);
      myTargetWindow.removeWindowListener(myWindowListener);
      myTargetWindow.removeWindowStateListener(myWindowStateListener);

      final Container parent = myPointerComponent.getParent();
      final Rectangle bounds = myPointerComponent.getBounds();
      if (parent != null) {
        parent.remove(myPointerComponent);
        parent.repaint(bounds.x, bounds.y, bounds.width, bounds.height);
      }
    };

    SwingUtilities.invokeLater(runnable);
  }
private void dispose()