title: Why is getPreferredSize() returning a size that is too small for this JDialog?
body: <p>In our product, we have frames that are basically three inheritance levels down from what is essentially a <code>JDialog</code>.  This frame overrides the default <code>pack()</code> method as shown:</p>
  
  <pre><code>@Override
  public void pack() {
      this.setSize(getMaximumSize());
      validate();
      super.pack();
  }
  
  @Override
  public Dimension getMaximumSize(){
      return super.getPreferredSize();
  }
  </code></pre>
  
  <p><code>pack()</code> here gets called after pretty much everything is on the screen.  Lots of these windows have a title bar, a couple of tool bars, a pane that holds the main content (can often be mostly empty), and a status bar at the bottom.</p>
  
  <p>My problem appears to be that when it calls the <code>getPreferredSize()</code> for the container, the result is just too small, i.e. the width seems okay, but the height isn't.  Reading through the docs, it seems like the preferred size is computed based on the layout manager if it isn't set explicitly (which I'm pretty sure it isn't).  I'm not quite sure how it calculates or if I should be doing something else first.</p>
  
  <p>Anybody have any idea or thoughts as to what my problem could be here? It's not always too small, just some of the time.  Please let me know what other information/code may be helpful to figuring this out.  Thanks.</p>