title: When creating JComboBoxes inside a JPanel, is it possible to control the size (specifically the height) of the each JComboBox
body: <p>I have created a <code>JPanel</code> in which I am creating varying numbers of <code>JComboBoxes</code>. The number of <code>JComboBoxes</code> being put in depends on varying conditions before hand.</p>
  
  <p>The problem I have is that when I create these <code>JComboBoxes</code> they automatically fit to the full size of the <code>JPanel</code>, please see images below. </p>
  
  <p><img src="https://i.stack.imgur.com/dm0Qs.png" alt="enter image description hereImage where just one &lt;code&gt;JComboBox&lt;/code&gt; is created which takes up the whole JPanel()"></p>
  
  <p>Is there any way for me to fix the size of this <code>JComboBox</code> so it is smaller than the full size of the <code>JPanel</code>?</p>
  
  <hr>
  
  <p>FOLLOW UP INFORMATION</p>
  
  <hr>
  
  <p>Thank you for your interest and help</p>
  
  <p>I am using the Netbeans development tool. I first created a JScrollPanel and then put the JPanel inside this JScrollPanel using NetBeans and which creates these in uneditable code in initComponents().</p>
  
  <p>I can provide all the code for this but it is a sizable amount and may not be useful, it begins:</p>
  
  <pre><code>    jScrollPane = new javax.swing.JScrollPane();
      isotopePanel = new javax.swing.JPanel();
  
      jScrollPane.setBorder(javax.swing.BorderFactory.createTitledBorder("Isotope Details"));
  
      isotopePanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
      isotopePanel.setAutoscrolls(true);
  
      javax.swing.GroupLayout isotopePanelLayout = new javax.swing.GroupLayout(isotopePanel);
      isotopePanel.setLayout(isotopePanelLayout);
      isotopePanelLayout.setHorizontalGroup(
          isotopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addGap(0, 755, Short.MAX_VALUE)
      );
      isotopePanelLayout.setVerticalGroup(
          isotopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addGap(0, 356, Short.MAX_VALUE)
      );
  
      jScrollPane.setViewportView(isotopePanel);
  
      .....
  </code></pre>
  
  <p>In my code, in aboutToDisplay() I created the JComboBoxe(s) and labels for them in an array called LabelsAndCombos and then put these into the Jpanel using the code:</p>
  
  <pre><code>    javax.swing.GroupLayout isotopesLayout = new javax.swing.GroupLayout(isotopePanel);   
  
      isotopesLayout.setAutoCreateGaps(true);
      isotopesLayout.setAutoCreateContainerGaps(true);
  
      javax.swing.GroupLayout.SequentialGroup hGroup = isotopesLayout.createSequentialGroup();
      javax.swing.GroupLayout.SequentialGroup vGroup = isotopesLayout.createSequentialGroup();
  
      GroupLayout.ParallelGroup labelGroup = isotopesLayout.createParallelGroup();
      GroupLayout.ParallelGroup comboBoxGroup = isotopesLayout.createParallelGroup();
      for(int i=0;i&lt;calcDef.getAtomLabels().length;i++){
          labelGroup.addComponent(labelsAndCombos[i].label);
          comboBoxGroup.addComponent(labelsAndCombos[i].combo);
          vGroup.addGroup(isotopesLayout.createParallelGroup().addComponent(labelsAndCombos[i].label).addComponent(labelsAndCombos[i].combo));
      }
  
      hGroup.addGroup(labelGroup);
      hGroup.addGroup(comboBoxGroup);
  
      isotopesLayout.setHorizontalGroup(hGroup);
      isotopesLayout.setVerticalGroup(vGroup);
  
      isotopePanel.setLayout(isotopesLayout);
  </code></pre>
  
  <p>Please let me know if I can provide more information to make this clearer.</p>
  
  <p>Thank you</p>