private void adjustSizeToContent() {
    if (isDisposed()) return;
    Dimension prefSize = getPreferredSize();
    Dimension minSize = getRootPane().getMinimumSize();
    int height = Math.max(prefSize.height, minSize.height);
    setSize(prefSize.width, height);
  }
private void adjustSizeToContent()