I'm trying to convert a
String to a double value. My book says to first create a Double object and then convert the Double to a double value. It's not working... anybody got any ideas?
Thanks!
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class CalcPay extends
Applet implements ActionListener
{
TextField text1 = new TextField("hours worked",15);
TextField text2 = new TextField("hourly rate", 15);
Button button = new Button("Press Me");
Label label = new Label(" ");
public void init()
{
add(text1);
add(text2);
add(button);
add(label);
button.addActionListener(this);
invalidate();
validate();
}
public void actionPerformed(ActionEvent e)
{
String text1Number = text1.getText();
String text2Number = text2.getText();
Double text1Double = Double.valueOf(text1Number);
Double text2Double = Double.valueOf(text2Number);
double text1double = doubleValue(text1Double);
double text2double = doubleValue(text2Double);
}
}