Java Reference
In-Depth Information
double
value
=
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");
}
}
};
Button btnConvertToCelsius = new Button("convert to
celsius");
btnConvertToCelsius.addActionListener(al);
pnlLayout.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");
}
}
};
Button btnConvertToFahrenheit = new Button("convert
Search WWH ::




Custom Search