title: Change the size of CardLayout in Swing
body: <p>I am unable to align the gridpanels in Swing because of fixed size of CardLayout.</p>
  
  <p>I have a gridPanel gpTenderTypes for which i have used the Card Layout.</p>
  
  <pre><code> gpTenderTypes.setLayout(new CardLayout());
  </code></pre>
  
  <p>When a button is clicked, the card will change and the class will be called (for example, when creditcard button is clicked, creditcard card in the grid panel will be shown and the Card1() object will be called.</p>
  
  <pre><code>gpTenderTypes.add(new Cash1(), DBConstants.TENDER_TYPE_CASH);
  gpTenderTypes.add(new Card1(), DBConstants.TENDER_TYPE_CREDIT_CARD);
  </code></pre>
  
  <p>gpTenderTypes is added in another gridPanel gp2row along with 2 other gridpanels.</p>
  
  <pre><code>gp2row.addFilledComponent(gpCustDet, 1, 1, 6, 1,GridBagConstraints.BOTH);
  gp2row.addFilledComponent(gpTT, 1, 7, 1, 1, GridBagConstraints.BOTH);        
  gp2row.addFilledComponent(gpButtonsPanel, 1, 8, 6, 1,GridBagConstraints.BOTH);
  </code></pre>
  
  <p>gp2row is added in the screen:</p>
  
  <pre><code>this.addFilledComponent(gp2row, 2, 1, 14, 1, GridBagConstraints.BOTH);
  </code></pre>
  
  <p>I've realized that the size of the CardLayout remains constant  irrespective of changing its size using setSize or setPreferredSize. Changing the dimensions of the other GridPanels (gpCustDet, gpButtonsPanel) is of no use either.</p>
  
  <p>How do i do fix this?
  Thank you! </p>