Java Reference
In-Depth Information
Double.parseDouble(txtDegrees.getText());
double result = (value-32.0)*5.0/9.0;
txtResult.setText("Celsius
=
"+res-
ult);
}
catch (NumberFormatException nfe)
{
System.err.println("bad input");
}
}
};
JButton btnConvertToCelsius = new JButton("Convert to
Celsius", ii);
btnConvertToCelsius.addActionListener(al);
pnlTemp.add(btnConvertToCelsius);
al = new ActionListener()
{
@Override
public void actionPerformed(ActionEvent ae)
{
try
{
double
value
=
Double.parseDouble(txtDegrees.getText());
double result = value*9.0/5.0+32.0;
txtResult.setText("Fahrenheit = "+res-
ult);
}
catch (NumberFormatException nfe)
{
System.err.println("bad input");
}
}
};
JButton btnConvertToFahrenheit = new JButton("Convert
to Fahrenheit", ii);
Search WWH ::




Custom Search