title: How to add checkboxes in list in java
body: <p>Hey everyone I am trying to add checkboxes into JList but for some reasons it's giving me <code>IllegalArgumentException</code>. If anyone know how to add checkbox in JList please tell me. Thank you in advance</p>
  
  <pre><code>    JCheckBox []data={
      new JCheckBox("C"),
      new JCheckBox("C++"),
      new JCheckBox("Java"),
      new JCheckBox("C sharp")};
      JList l=new JList(data);
      JScrollPane sp=new  JScrollPane(l,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED,ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
  </code></pre>