title: How to fit a JPanel into a JTabbedPane size?
body: <p>I'm trying to add a <code>JPanel</code> into another and to fit it to the parent `JPanel size.</p>
  
  <p>I have a <code>JPanel</code> which contains a <code>JTable</code> and a <code>JButton</code> using this code:</p>
  
  <pre><code>JScrollPane attributeTable = new JScrollPane(this);
  
  JPanel attributesPanel = new JPanel();
  
  JPanel textFieldPanel=new JPanel();
  JPanel buttonsPanel = new JPanel();
  
  JButton newAttributeButton = new JButton("New Attribute");
  
  attributesPanel.add(textFieldPanel, BorderLayout.CENTER);
  attributesPanel.add(buttonsPanel, BorderLayout.SOUTH);
  
  newAttributeButton.addActionListener(AttributesTableController.getInstance());
  
  GroupLayout layout = new GroupLayout(textFieldPanel);
  textFieldPanel.setLayout(layout);
  
  // Turn on automatically adding gaps between components
  layout.setAutoCreateGaps(true);
  
  // Turn on automatically creating gaps between components that touch
  // the edge of the container and the container.
  layout.setAutoCreateContainerGaps(true);
  
  // Create a sequential group for the horizontal axis.
  
  GroupLayout.SequentialGroup hGroup = layout.createSequentialGroup();
  
  // The sequential group in turn contains two parallel groups.
  // One parallel group contains the labels, the other the text fields.
  // Putting the labels in a parallel group along the horizontal axis
  // positions them at the same x location.
  //
  // Variable indentation is used to reinforce the level of grouping.
  hGroup.addGroup(layout.createParallelGroup().
           addComponent(attributeTable).addComponent(newAttributeButton));
  layout.setHorizontalGroup(hGroup);
  
  // Create a sequential group for the vertical axis.
  GroupLayout.SequentialGroup vGroup = layout.createSequentialGroup();
  vGroup.addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(attributeTable));
  vGroup.addGroup(layout.createParallelGroup(Alignment.CENTER).
           addComponent(newAttributeButton));
  layout.setVerticalGroup(vGroup);
  </code></pre>
  
  <p>When I had this panel (named <code>attributesPanel</code>) into a tab of a <code>JTabbedPane</code>, it just display the <code>JTable</code> and the <code>JButton</code>, but in the center of the panel. I would like that the dimension of <code>attributesPanel</code> are the same as the dimension of opened tab.</p>
  
  <p>This is the code I use to add the JPanel into my JTabbedPane:</p>
  
  <pre><code>TabbedPane tabbedPane = new TabbedPane();
  tabbedPane.setComponentAt(1, attributesPanel);
  </code></pre>
  
  <p>I tried using a <code>GridLayout</code>, it fitted the <code>JPanel</code> well but I was not able to resize the button. I tried with a <code>FlowLayout</code> and a <code>GridBagLayout</code>, but I was not able to display them correctly because I had the same problem.</p>
  
  <p>Thank you in advance.</p>