title: Error when using Double.parseDouble from text field
body: <p>i have been trying to take an input from a text field and put it in a Double variable. but when ever i try to use <code>Double.parseDouble(textTF.getText())</code> i get errors, i tested using scanner it worked fine</p>
  
  <pre><code>private class NumRTFHandler implements ActionListener {
      public void actionPerformed(ActionEvent e) {
          String romanN = "";
          String dec = numDTF.getText();
          Double decimal = Double.parseDouble(dec);
      }
  }
  </code></pre>
  
  <p>i guessed it might be the Action listener but im not sure how to deal with it. <code>Double.parseDouble()</code> didn't work neither with a textField nor with a string. </p>
  
  <p>please Help.</p>
  
  <p>these are the errors.</p>
  
  <pre><code>Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: empty String
  at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source)
  at java.lang.Double.parseDouble(Unknown Source)
  at RomanNumeralConvertert$NumRTFHandler.actionPerformed(RomanNumeralConvertert.java:40)
  at javax.swing.JTextField.fireActionPerformed(Unknown Source)
  at javax.swing.JTextField.postActionEvent(Unknown Source)
  at javax.swing.JTextField$NotifyAction.actionPerformed(Unknown Source)
  at javax.swing.SwingUtilities.notifyAction(Unknown Source)
  at javax.swing.JComponent.processKeyBinding(Unknown Source)
  at javax.swing.JComponent.processKeyBindings(Unknown Source)
  at javax.swing.JComponent.processKeyEvent(Unknown Source)
  at java.awt.Component.processEvent(Unknown Source)
  at java.awt.Container.processEvent(Unknown Source)
  at java.awt.Component.dispatchEventImpl(Unknown Source)
  at java.awt.Container.dispatchEventImpl(Unknown Source)
  at java.awt.Component.dispatchEvent(Unknown Source)
  at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
  at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)
  at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source)
  at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)
  at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
  at java.awt.Component.dispatchEventImpl(Unknown Source)
  at java.awt.Container.dispatchEventImpl(Unknown Source)
  at java.awt.Window.dispatchEventImpl(Unknown Source)
  at java.awt.Component.dispatchEvent(Unknown Source)
  at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
  at java.awt.EventQueue.access$200(Unknown Source)
  at java.awt.EventQueue$3.run(Unknown Source)
  at java.awt.EventQueue$3.run(Unknown Source)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
  at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
  at java.awt.EventQueue$4.run(Unknown Source)
  at java.awt.EventQueue$4.run(Unknown Source)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
  at java.awt.EventQueue.dispatchEvent(Unknown Source)
  at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
  at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
  at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
  at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
  at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
  at java.awt.EventDispatchThread.run(Unknown Source)
  </code></pre>
  
  <p>I declared numDTF at the top</p>
  
  <pre><code>JTextField numDTF;
  </code></pre>
  
  <p>and it gets the input from the user.</p>
  
  <p>Edit:</p>
  
  <p>here is the whole code</p>
  
  <pre><code>import javax.swing.*;
  import java.awt.*;
  import java.awt.event.*;
  
  public class RomanNumeralConvertert extends JFrame {
  
    private static final int HEIGHT = 60;  
    private static final int WIDTH = 600;
  
    private JLabel numRL, numDL;  
    private JTextField numRTF, numDTF;
    private NumRTFHandler nrh;
    private NumDTFHandler ndh;
  
    public RomanNumeralConvertert() {
      setTitle("Roman Numeral to Decimal Converter");                  
      numRL = new JLabel("Decimal Value: ", SwingConstants.RIGHT);
      numDL = new JLabel("Roman Numeral: ", SwingConstants.RIGHT);
      numRTF = new JTextField(10);
      numDTF = new JTextField(10);
      nrh = new NumRTFHandler();
      ndh = new NumDTFHandler();
      numRTF.addActionListener(nrh);
      numDTF.addActionListener(ndh);
  
      Container pane = getContentPane();            
      pane.setLayout(new GridLayout(1, 4));
      pane.add(numDL); pane.add(numDTF);
      pane.add(numRL); pane.add(numRTF);
  
      setSize(WIDTH, HEIGHT);                     
      setVisible(true);
      setDefaultCloseOperation(EXIT_ON_CLOSE);
    }
  
    private class NumRTFHandler implements ActionListener {
      public void actionPerformed(ActionEvent e) {
        String romanN = "";
        String dec = numDTF.getText();
        Double decimal = Double.parseDouble(dec);
        //converting to Roman Numerals 
        while(decimal &gt;= 1000){
          romanN += "M";
          decimal -= 1000.0;  
        }
        while(decimal &gt;= 900){
          romanN += "CM";
          decimal -= 900;  
        }
        while(decimal &gt;= 500){
          romanN += "D";
          decimal -= 500;  
        }
        while(decimal &gt;= 400){
          romanN += "CD";
          decimal -= 400;  
        }
        while(decimal &gt;= 100){
          romanN += "C";
          decimal -= 100;  
        }
        while(decimal &gt;= 90){
          romanN += "XC";
          decimal -= 90;  
        }
        while(decimal &gt;= 50){
          romanN += "L";
          decimal -= 50;  
        }
        while(decimal &gt;= 40){
          romanN += "XL";
          decimal -= 40;  
        }
        while(decimal &gt;= 10){
          romanN += "X";
          decimal -= 10;  
        }
        while(decimal &gt;= 9){
          romanN += "IX";
          decimal -= 9;  
        }
        while(decimal &gt;= 5){
          romanN += "V";
          decimal -= 5;  
        }
        while(decimal &gt;= 4){
          romanN += "IV";
          decimal -= 4;  
        }
        while(decimal &gt;= 1){
          romanN += "I";
          decimal -= 1;  
        }
        numRTF.setText(romanN);
      }
    }
  
    private class NumDTFHandler implements ActionListener {
      public void actionPerformed(ActionEvent e) {
        String romanN = numDTF.getText();
        double decimal = 0;
        romanN.toUpperCase();
        int i=0;
        while(i &lt;= romanN.length()){
          char char1 = romanN.charAt(i);
          i++;
          char char2 ='i';
          if(i &lt; romanN.length()){
            char2 = romanN.charAt(i+1);
            i++;
          }
          if( char1 == ('M')){
            decimal +=1000;
          }
          if( char1 == ('D')){
            decimal +=500;
          }
          if( char1 ==('C')){
            if( char2 == ('M')){
              decimal +=900;
            }
            if( char1 == ('D')){
              decimal +=400;
            }
          }else{
            decimal += 100;
          }
          if( char1 == ('L')){
            decimal +=50;
          }
          if( char1 == ('X')){
            if( char2 == ('C')){
              decimal +=90;
            }
            if( char1 == ('L')){
              decimal +=40;
            }
          }else{
            decimal += 10;
          }
          if( char1 == ('V')){
            decimal +=5;
          }
          if( char1 == ('1')){
            if( char2 == ('X')){
              decimal +=9;
            }
            if( char1 == ('V')){
              decimal +=4;
            }
         }else{
            decimal += 1;
         }
        }
        numDTF.setText("" + decimal);
  
      }
    }
  
    public static void main(String[] args) {
      RomanNumeralConvertert gui = new RomanNumeralConvertert();
    }
    // End of the Code
  }
  </code></pre>
  
  <p>I couldn't figure it out, i checked the logic and no problems with that.</p>
  
  <p>edit:</p>
  
  <p>i have solved the problem that caused the empty string. there were some text fields names 
  switched together, just needed to change the names, it is working now, and the logic here had few problem but solved that too. </p>