title: Convert String to Double - JAVA
body: <pre><code>private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {                                           
          // TODO add your handling code here:
  
          //9
  
  
          txtTot.setText(jComboBox1.getSelectedItem().toString());
          tot= Double.parseDouble(txtTot.getText());
          CMB= (Double)jComboBox1.getSelectedItem();
          Total2=tot+CMB;
          txtTot.setText(Double.toString(Total2));
  
      }   
  </code></pre>
  
  <p>From the <code>ComboBox</code> I'm setting the <code>jtextfield</code> and the second line I'm taking the <code>string</code> from the <code>textfield</code> and trying to convert it into a <code>double</code>.</p>
  
  <p>Error below:</p>
  
  <pre><code>Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Double
      at test.Test.jComboBox1ActionPerformed(Test.java:392)
      at test.Test.access$600(Test.java:18)
      at test.Test$7.actionPerformed(Test.java:134)
      at javax.swing.JComboBox.fireActionEvent(JComboBox.java:1258)
      at javax.swing.JComboBox.setSelectedItem(JComboBox.java:586)
      at javax.swing.JComboBox.setSelectedIndex(JComboBox.java:622)
  </code></pre>