Program Not Compiling
Here is my code, the errors are listed at the bottom. Please help, I've been trying to figure this out for 2 hours! This was done using JCreator as my IDE. Instructions on how to fix this would help too. Thanks for your time!
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.text.DecimalFormat;
public class TempConversion
{
//Necessary GUI components
JLabel celsL;
JLabel fahrL;
JTextField celsTF;
JTextField fahrTF;
//Handlers, used to listen for actions and act accordingly
CelsHandler celsH;
FahrHandler fahrH;
public TempConversion()
{
//Content pane to place all components
Container c = getContentPane();
c.setLayout(new GridLayout(1,4));
//Setting the JLabels
celsL = new JLabel("Celsius: ",SwingConstants.RIGHT);
fahrL = new JLabel("Fahrenheit: ",SwingConstants.RIGHT);
//Setting the JTextFields
celsTF = new JTextField(10);
fahrTF = new JTextField(10);
//Activating celsH and fahrH as objects of CelsHandler and FahrHandler,
//respectively
celsH = new CelsHandler();
fahrH = new FahrHandler();
//Adding the action listeners to the TextFields
celsTF.addActionListener(celsH);
fahrTF.addActionListener(fahrH);
//Adding the components to the content pane
c.add(celsL);
c.add(celsTF);
c.add(fahrL);
c.add(fahrTF);
//Window settings
setTitle("Temperature Conversion");
setVisible(true);
setSize(500,100);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
//The CelsHandler class
private class CelsHandler implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
DecimalFormat digit = new DecimalFormat("0.00");
double cels, fahr;
//Extracting information from the celsius textfield
cels = Double.parseDouble(celsTF.getText());
fahr = (cels * (9 / 5)) + 32;
fahrTF.setText("" + fahr);
}
}
//The FahrHandler class
private class FahrHandler implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
DecimalFormat digit = new DecimalFormat("0.00");
double cels, fahr;
//Extracting information from the celsius textfield
fahr = Double.parseDouble(fahrTF.getText());
cels = ((fahr - 32) * (5 / 9));
celsTF.setText("" + cels);
}
}
public static void main(String[] args)
{
TempConversion tempConv = new TempConversion();
}
}
The Errors:
C:\Documents and Settings\Jeffrey Chia\Java Programs\TempConversion\src\TempConversion.java:28: cannot find symbol
symbol : method getContentPane()
location: class TempConversion
Container c = getContentPane();
^
C:\Documents and Settings\Jeffrey Chia\Java Programs\TempConversion\src\TempConversion.java:54: cannot find symbol
symbol : method setTitle(java.lang.String)
location: class TempConversion
setTitle("Temperature Conversion");
^
C:\Documents and Settings\Jeffrey Chia\Java Programs\TempConversion\src\TempConversion.java:55: cannot find symbol
symbol : method setVisible(boolean)
location: class TempConversion
setVisible(true);
^
C:\Documents and Settings\Jeffrey Chia\Java Programs\TempConversion\src\TempConversion.java:56: cannot find symbol
symbol : method setSize(int,int)
location: class TempConversion
setSize(500,100);
^
C:\Documents and Settings\Jeffrey Chia\Java Programs\TempConversion\src\TempConversion.java:57: cannot find symbol
symbol : variable EXIT_ON_CLOSE
location: class TempConversion
setDefaultCloseOperation(EXIT_ON_CLOSE);

