java – Problems converting degrees Celsius to Fahrenheit

Here is the problem:

I need to make an application that converts from Celsius to Fahrenheit by interacting with a JPanel, some JTextField or and a JButton. The problem I have is that when I enter a number in the JTextField I do the calculation in degrees Celsius, that is to say that I calculate the Fahrenheit on the basis of Celsius. To do it the opposite way, it is not the case.

Public class Window extends JFrame {

JPanel jp;
JTextField cajaCelsius;
JTextField cajaFarenheit;
JLabel labelCelsius;
JLabel EtiquetaFarenheit;
JButton conversion;
double degrees of Farenheit = 0.0;
double degrees Celsius = 0.0;

public window () {
setSize (400, 200);
setLocationRelativeTo (null);
setDefaultCloseOperation (EXIT_ON_CLOSE);
setTitle ("Converting Celsius into Farenheit and vice versa");
homeComponents ();
}

private void homeComponents () {
jp = new JPanel ();
jp.setLayout (null); // We set the default layout to null
Tags ();
boxWrite ();
Buttons ();
this.getContentPane (). add (jp); // We add to the window panel
}

Private void tags () {
labelCelsius = new JLabel ();
labelCelsius.setText ("Celsius:");
labelCelsius.setBounds (70, 0, 100, 100);
tagFarenheit = new JLabel ();
tagFarenheit.setText ("Farenheit:");
tagFarenheit.setBounds (50, 30, 100, 100);
jp.add (labelCelsius);
jp.add (tagFarenheit);
}

Private void buttons () {
conversion = new JButton ();
conversion.setBounds (170, 100, 100, 50);
conversion.setText ("Conversion");
jp.add (conversion);

ActionListener al = new ActionListener () {

double degrees;

@Override
public void actionPerformed (ActionEvent e) {
try {
System.out.println ("iee");
// If you write about Celsius
if (boxCelsius.getText ()! = "0.0") {
degrees = Double.parseDouble (boxCelsius.getText ());
degrees Farenheit = (degrees * (9.0 / 5.0)) + 32;
System.out.println ("Estique at first si, grausTeclat:" + degrees + ", grausFarenheit:" + gradosFarenheit);
String s = ("" + degrees Farenheit);
cajaFarenheit.setText (s);
System.out.println ("Farenheit:" + gradosFarenheit);
}
// If you write about Farenheit
else if (cajaFarenheit.getText ()! = "32.0") {
System.out.println ("did you touch is farenheit");
degrees = Double.parseDouble (cajaFarenheit.getText ());
degrees Celsius = ((degrees - 32.0) * (5.0 / 9.0));
System.out.println ("Estic to segon if, grausTeclat:" + degrees + ", grausCelsius:" + gradosCelsius);
String s = ("" + degrees Celsius);
cajaCelsius.setText (s);
System.out.println ("Celsius:" + degrees Celsius);
}
} catch (NumberFormatException a) {
System.out.println ("estic a s" exception);
boxCelsius.setText ("0.00");
cajaFarenheit.setText ("32.00");
}

}
};

conversion.addActionListener (al);
}

private void boxWrite () {
boxCelsius = new JTextField ();
cajaCelsius.setBounds (120, 40, 250, 20);
boxCelsius.setText ("0.0");
cajaFarenheit = new JTextField ();
caja Farenheit.setBounds (120, 70, 250, 20);
cajaFarenheit.setText ("32.0");
jp.add (boxCelsius);
jp.add (cajaFarenheit);
}
}

If you run the code, it works perfectly. Maybe in the part of ActionListener I did not put the if-else Well, if I was wrong, I would not even get into the first one.