title: Formatting many checkboxes on Jframe or Jpanel
body: <p>I have already a collection(List) of sentences. So I need to put every single sentences in a check box.The number of check boxes depends on the number of Vector Size. For example, I have 50 sentences, so I need 50 check boxes. Then user can check the desired sentences to be written in a text file.
  The following class (ViewerFrame) is supposed to build a frame to have many checkboxes the same as the number of sentences in the array list(ManualSummarySys.sentences).Class (ManualSummarySys) is working perfectly.</p>
  
  <pre><code>public class ViewerFrame {
  
  import java.awt.BorderLayout ;
  import java.awt.Font ;
  import java.awt.GridLayout ;
  import java.awt.ScrollPane ;
  import java.awt.event.ActionEvent ;
  import java.awt.event.ActionListener ;
  import java.util.ArrayList ;
  import java.util.List ;
  import javax.swing.ButtonGroup ;
  import javax.swing.JButton ;
  import javax.swing.JCheckBox ;
  import javax.swing.JComboBox ;
  import javax.swing.JFrame ;
  import javax.swing.JLabel ;
  import javax.swing.JPanel ;
  import javax.swing.JRadioButton ;
  import javax.swing.border.EtchedBorder ;
  import javax.swing.border.TitledBorder ;
  import javax.swing.plaf.metal.MetalBorders ;
  
  public class ViewerFrame extends JFrame {
  
      private static final int FRAME_WIDTH = 10;
      private static final int FRAME_HEIGHT = 5;
      private JLabel sampleField;
      private List&lt;JCheckBox&gt; checkboxes = new ArrayList&lt;JCheckBox&gt;();
      private ActionListener listener;
  
      public ViewerFrame() {
  
          sampleField = new JLabel("choose your prefered sentences");
          add(sampleField, BorderLayout.WEST);
  
          class ChoiceListener implements ActionListener {
  
              public void actionPerformed(ActionEvent event) {
              }
          }
          listener = new ChoiceListener();
          createControlPanel();
  
          setSize(FRAME_WIDTH, FRAME_HEIGHT);
          add(this.createCheckBoxes());
  
      }
  
      public void createControlPanel() {
          JFrame sizeGroupPanel = createCheckBoxes();
  
  
          JPanel controlPanel = new JPanel();
          controlPanel.setLayout(new GridLayout(3, 1));
  
          controlPanel.add(sizeGroupPanel);
          controlPanel.add(styleGroupPanel);
  
          add(controlPanel, BorderLayout.LINE_START);
  
      }
  
      public JFrame createCheckBoxes() {
          JFrame frame = new JFrame("Sentences");
          frame.setBorder(new TitledBorder(new EtchedBorder(), "Sentences"));
          for (int i = 0; i &lt; ManualSummarySys.sentences.size(); i++) {
              JCheckBox checkbox = new JCheckBox(ManualSummarySys.sentences.get(i));
              checkboxes.add(checkbox);
              checkbox.addActionListener(listener);
              frame.add(checkbox);
  
          }
          return frame;
      }
  }
  </code></pre>