title: how to get a Integer value from a Combo box in java?
body: <p>I've created a class named as <strong>fontlist</strong> and I want to get the Integer value from the Combo box, but it gives me some error.</p>
  
  <p>How do I get an Integer value from the Combo box?  Also, I want to change the size of text according to an integer value that gets to the fontsize Combo Box ...</p>
  
  <p>My code is:</p>
  
  <pre><code>        import java.awt.*;
          import javax.swing.*;
          import java.awt.event.*;
          import java.util.*;
  
          class fontlist extends JFrame implements ItemListener
          { JComboBox jcb,fontSize;
          Container content;
          JTextArea jta;
          JScrollPane jsp;
          private static final int[] fontsize = {8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72};
  
          fontlist()
          {
          content=getContentPane();
          setLayout(null);
          setBackground(Color.WHITE);
          jcb=new JComboBox();
          content.add(jcb);
          jcb.setBounds(100,100,100,20);
  
          fontSize=new JComboBox();
          content.add(fontSize);
          fontSize.setBounds(200,100,100,20);
          jta=new JTextArea();
          jsp=new JScrollPane(jta);
          content.add(jsp);
          jsp.setBounds(100,120,200,200);
          jcb.addItemListener(this);
          fontSize.addItemListener(this);
          String fonts[] = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
          for ( int i = 0; i &lt; fonts.length; i++ )
          {
          jcb.addItem(fonts[i]);
          } 
          for ( int j = 0; j &lt;16; j++ )
          {
          fontSize.addItem(fontsize[j]);
          } 
          }
          public void itemStateChanged(ItemEvent ie)
          {
          if (ie.getStateChange() == ItemEvent.SELECTED) 
          {
          System.out.println(""+fontSize.getSelectedItem());
            String size = (fontSize.getSelectedItem()+"");
           System.out.println(size);
           int size1 =Integer(size);
          }
          }
          public static void main(String args[])
          {
          fontlist fl=new fontlist();
          fl.setSize(700,500);
          fl.setVisible(true);
          }
  
          }
  </code></pre>
  
  <p>And the error is:</p>
  
  <p><img src="https://i.stack.imgur.com/UE8i3.png" alt="enter image description here"></p>