title: String cannot be cast to java error: Trying to convert string into integer
body: <p>When trying to add years from a combobox this error shows:</p>
  
  <p>Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer </p>
  
  <p>at LibraryFrame$addListener.actionPerformed(LibraryFrame.java:103)</p>
  
  <p>The program highlights the 'Integer anInteger = (Integer) selected;' line as the problem?   </p>
  
  <pre><code>class addListener implements ActionListener
  {
      public void actionPerformed(ActionEvent e)
      {
           Object selected = yearCombo.getSelectedItem(); 
  
          if(e.getSource() == button)
          {
              System.out.println("Add button clicked!");
              String t = title.getText();
              Integer anInteger = (Integer) selected;
              int y = anInteger;
              int q = Integer.parseInt(quantity.getText());
              library.addItem(new LibraryItem(t,y,q));
              library.printLibrary();
  
              System.out.println("Thank You!");
          }
      }
  }
  </code></pre>
  
  <p>Heres the code where yearCombo is populated:</p>
  
  <pre><code>label1 = new JLabel("Year");
      yearCombo = new JComboBox();
      ArrayList&lt;Integer&gt; countYear = new ArrayList&lt;Integer&gt;();
      for(int y=1800; y&lt;=2014; y++)
      {
          countYear.add(y);
      }
      for(int x=0; x &lt; countYear.size(); x++)
      {
          yearCombo.addItem((countYear.get(x) + " "));            
  
      }               
  </code></pre>
  
  <p>CODE NOW THROWING A NUMBER FORMAT EXCEPTION after changing</p>
  
  <pre><code>    Integer anInteger = (Integer) selected;
  </code></pre>
  
  <p>to</p>
  
  <pre><code>    Integer anInteger = Integer.parseInt(selected.toString());
  </code></pre>