title: Pack, but don't make it smaller
body: <p>I have <code>JFrame</code> with <code>GridBagLayout</code>. User can resize this window. Also, he can perform some editing actions that change window size. I use <code>pack(); repaint();</code> now after such actions. But, actually I shouldn't make window smaller after such operations - only bigger. What I found as solution is</p>
  
  <pre><code>    Dimension oldSize = getSize();
      pack();
      Dimension newSize = window.getSize();
      setSize(
              (int) Math.max(newSize.getWidth(), oldSize.getWidth()),
              (int) Math.max(newSize.getHeight(), oldSize.getHeight()));
      repaint();
  </code></pre>
  
  <p>But I don't like this solution at all. Beside ugly code, we set size twice (once by pack and than directly). Is there any other solutions? </p>