import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;

public class GestionJTextField implements DocumentListener {


	private JTextField aConvertir;
	private JTextField convertirVers;
	private boolean cToF;

	public GestionJTextField(JTextField aConvertir, JTextField convertirVers, boolean cToF) {
		this.aConvertir = aConvertir;
		this.convertirVers = convertirVers;
		this.cToF = cToF;
	}


	public void changedUpdate(DocumentEvent e) {
	}


	public void insertUpdate(DocumentEvent e) {
		try {
			if (this.cToF) {
				this.convertirVers.setText(Conversion.celsiusAFahrenheit(Double.parseDouble(this.aConvertir.getText())) + "");
			}
			else {
				this.convertirVers.setText(Conversion.FahrenheitACelsius(Double.parseDouble(this.aConvertir.getText())) + "");
			}
		} catch (NumberFormatException e2) {
			try {
				this.convertirVers.setText("???");
			} catch (IllegalStateException ee) {
			}
		} catch (IllegalStateException e3) {
		} finally {
			this.convertirVers.repaint();
		}
	}


	public void removeUpdate(DocumentEvent e) {
	}
}