public class H11_Oefening1 extends JFrame
{
	private JLabel labelFahrenheit, labelCelcius;
	private JTextField textfieldFahrenheit, textfieldCelcius;
	
	public Convert()
	{		
		super("Convert F to C");
		labelFahrenheit = new JLabel("Aantal graden Fahrenheit");
		labelCelsius = new JLabel("Aantal graden celsius");
		textfieldFahrenheit = new TextField(10);
		textfieldCelsius = new TextField(10);
		textfieldCelsius.setEditable(false);
		
		Container.container = getContentPane();
		container.add(labelFahrenheit);
		container.add(textfieldFahrenheit);
		container.add(labelCelsius);
		container.add(textfieldCelsius);
		
		TextFieldHandler handler = new TextFieldHandler();
		textfieldFahrenheit.addActionListener(handler);
		
		setSize(500,500);
		setVisible(true);
	}
	
	public static void main (String args[])
	{
		Convert application = new Convert();
		application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
	
	private class TexFieldHandler implements ActionListener
	{
		public void actionPerformed(ActionEvent event)
		{
			int temp = Integer.parseInt(textfieldFahrenheit.getText());
			int celcius = (int) (5.0f / 9.0f * (temp - 32));
			textfieldCelsius.setText(String.valueOf(celcius));
		}
	}
}