title: How do I change JPanel inside a JFrame on the fly?
body: <p>To put it simple, there's a simple java swing app that consists of JFrame with some components in it. One of the components is a JPanel that is meant to be replaced by another JPanel on user action.</p>
  
  <p>So, what's the correct way of doing such a thing? I've tried</p>
  
  <pre><code>panel = new CustomJPanelWithComponentsOnIt();
  parentFrameJPanelBelongsTo.pack();
  </code></pre>
  
  <p>but this won't work. What would you suggest?</p>