Need help cleaning this up: Giving me errors because I don\'t have Main but when
ID: 3847645 • Letter: N
Question
Need help cleaning this up: Giving me errors because I don't have Main but when I put it in it doesn't run. Using Netbeans Java - Java Class Library.
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class Temper extends Applet {
private final Button Calculate;
private Label lblFahrenheit;
private Label lblCelsius;
private TextField txtFahrenheit;
private TextField txtCelsius;
private final Panel p;
private String label;
}
/**
* Initialization method that will be called after the applet is loaded into
* the browser.
*/
@Override
public static void main(String[] args)
// TODO start asynchronous download of heavy resources
}
{
setBackground (Color.blue);
p = new Panel ();
p.setLayout (new GridLayout (5, 1, 12, 12));
txtFahrenheit = setField (p, txtFahrenheit, lblFahrenheit, "Fahrenheit");
txtCelsius = setField (p, txtCelsius, lblCelsius, "Celsius");
Calculate = new Button ("Calculate");
Calculate.addActionListener ((ActionListener) new CalculateListener ());
p.add (Calculate);
add (p);
} // method init
private TextField setField(Panel p, TextField txtFahrenheit, Label lblFahrenheit, String fahrenheit) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
// Inner class to listen for the Calculate button.
class CalculateListener implements ActionListener
{
public void actionPerformed (ActionEvent event)
{
double fahrenheit, celsius;
fahrenheit = getDouble(txtFahrenheit);
celsius = (fahrenheit - 32) * 5 / 9;
txtCelsius.setText ("celsius");
} // method actionPerformed
} // class CalculateListener
Explanation / Answer
CORRECTED CODE:-
I have added main and corrected that problem but it is asking getDouble method defination which you haven't defined.Define it and remaining errors are corrected
Code:-
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.lang.*;
public class Temper extends Applet {
private final Button Calculate;
private Label lblFahrenheit;
private Label lblCelsius;
private TextField txtFahrenheit;
private TextField txtCelsius;
private final Panel p;
private String label;
/**
* Initialization method that will be called after the applet is loaded into
* the browser.
*/
public static void main(String[] args){
// TODO start asynchronous download of heavy resources
}
{
setBackground (Color.blue);
p = new Panel ();
p.setLayout (new GridLayout (5, 1, 12, 12));
txtFahrenheit = setField (p, txtFahrenheit, lblFahrenheit, "Fahrenheit");
txtCelsius = setField (p, txtCelsius, lblCelsius, "Celsius");
Calculate = new Button ("Calculate");
Calculate.addActionListener ((ActionListener) new CalculateListener ());
p.add (Calculate);
add (p);
} // method init
private TextField setField(Panel p, TextField txtFahrenheit, Label lblFahrenheit, String fahrenheit) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
// Inner class to listen for the Calculate button.
class CalculateListener implements ActionListener
{
public void actionPerformed (ActionEvent event)
{
double fahrenheit, celsius;
fahrenheit = getDouble(txtFahrenheit);
celsius = (fahrenheit - 32) * 5 / 9;
txtCelsius.setText ("celsius");
} // method actionPerformed
} // class CalculateListener
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.