protected void dispose() {
    ensureEventDispatchThread();
    myValidationAlarm.cancelAllRequests();
    myDisposed = true;

    for (JButton button : myButtonMap.values()) {
      button.setAction(null); // avoid memory leak via KeyboardManager
    }
    myButtonMap.clear();

    JRootPane rootPane = getRootPane();
    // if rootPane = null, dialog has already been disposed
    if (rootPane != null) {
      if (myActualSize != null && isAutoAdjustable()) {
        if (LOG.isDebugEnabled()) {
          LOG.debug("Resetting the size on dispose to the actual size " + myActualSize);
        }
        setSize(myActualSize.width, myActualSize.height);
      }
      myPeer.dispose();
    }
  }
protected void dispose()