Hi all,
I am trying to write a simple program but I am having an error message that I am working on it for three days. The aim of program is to convert entered value depending on the clicked radio buttons. Please can someone help me about it ?
Thanks,
The error message is as below:
Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: empty String
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:994)
at java.lang.Double.parseDouble(Double.java:510)
at converter.ValuePanel.getLatEntered(ValuePanel.java:29)
at converter.ConverterButtons.GetResult(ConverterButtons.java:46)
at converter.ConvertGUI$CalcButtonListener.actionPerformed(ConvertGUI.java:47)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6216)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
at java.awt.Component.processEvent(Component.java:5981)
at java.awt.Container.processEvent(Container.java:2041)
at java.awt.Component.dispatchEventImpl(Component.java:4583)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4413)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4556)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4220)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4150)
at java.awt.Container.dispatchEventImpl(Container.java:2085)
at java.awt.Window.dispatchEventImpl(Window.java:2475)
at java.awt.Component.dispatchEvent(Component.java:4413)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Here is the code for Double.java:510:
package converter;
import javax.swing.*;
import java.awt.*;
public class ValuePanel extends JPanel {
private JLabel valLabel;
private JTextField valTextField;
public ValuePanel()
{
setLayout(new GridLayout(1,2));
valLabel = new JLabel("Enter Latitude");
valTextField = new JTextField(10);
setBorder(BorderFactory.createTitledBorder("Latitude"));
add(valLabel);
add(valTextField);
}
public double getLatEntered()
{
//valTextField.setText("0");
String input;
double latitude;
input = valTextField.getText();
latitude = Double.parseDouble(input);
return latitude;
}
}