title: Storing Current Items From Comboboxes in an ArrayList
body: <p>I have a simple program that makes shapes of different sizes and colours.</p>
  
  <p>The shapes and colours are selected from ComboBoxes, while the size is controlled by a slider. I want to store the -currently selected- shape, size and the colour <strong>in an ArrayList of a new class that I defined</strong> by pressing a button and then print the info pressing another.</p>
  
  <pre><code>private ArrayList&lt;ShapeItem&gt; ShapeItem;
  
  
      slider = new JSlider (JSlider.HORIZONTAL,minValue,maxValue,initValue);
      add(slider);
      slider.addChangeListener(this);
  
  
      // Instantiate a new ComboBox with options for Shape
      shapeChoice = new JComboBox();
      shapeChoice.addItem("Point");
      shapeChoice.addItem("Square");
      shapeChoice.addItem("Circle");
      shapeChoice.addItem("Doughnut");
      shapeChoice.addItem("Pentagon");
      shapeChoice.addItem("Hexagon");
      add(shapeChoice); // Add the JComboBox to the JPanel
      shapeChoice.addActionListener(this);  //Register the JComboBox selection with Java
  
      // Instantiate a new ComboBox with options for Colour
      colorChoice = new JComboBox();
      colorChoice.addItem("Black");
      colorChoice.addItem("Red");
      colorChoice.addItem("Green");
  </code></pre>
  
  <p>Then:</p>
  
  <pre><code>readItems = new JButton("Read values");
      add(readItems);
      readItems.addActionListener(this);
  
      printItems = new JButton("List all values");
      add(printItems);
      printItems.addActionListener(this);
  
  ShapeItem = new ArrayList&lt;ShapeItem&gt;();  
  </code></pre>
  
  <p>My best bet at achieving that was introducting</p>
  
  <pre><code>if (e.getSource() == readItems)
      {
         String item0 = shapeChoice.getSelectedItem();
         String item1 = colorChoice.getSelectedItem(); 
  
  
      }
  
      // if the "List all values" button is pressed    
      else if (e.getSource() == printItems)
      {
          // loop through the ArrayList of items prnting each one out in turn to the JTextArea
          for (int j=0; j&lt;i; j++)
          {
             textOutput.append(itemList.get(j).shapeChoose + "\n");
             textOutput.append(itemList.get(j).colourChoose + "\n");
             textOutput.append("\n");
          }
      }
  </code></pre>
  
  <p><strong>But at the</strong></p>
  
  <p>String item0 = shapeChoice.getSelectedItem();</p>
  
  <p>I get an "incompatible types error"</p>
  
  <p>The new class I made is this:</p>
  
  <pre><code>public class ShapeItem
  </code></pre>
  
  <p>{</p>
  
  <pre><code>public String shapeChoose;
  public String colorChoose;
  public int thesize;
  </code></pre>
  
  <p>}</p>
  
  <p>Am I trying the right way or there is another method to achieve that?</p>