import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.text.DecimalFormat;

public class Opgave11_2Oplossing extends JFrame implements ActionListener {

    private JButton berekenBut;
    private JTextField feetTxt,inchesTxt,centimeterTxt;
    private JLabel feetLbl,inchesLbl,centimeterLbl;
    private double centimeters;

    public static void main(String[] args) {
        Opgave11_2Oplossing opgave11_2Oplossing = new Opgave11_2Oplossing();
        opgave11_2Oplossing.setSize(120,300);
        opgave11_2Oplossing.createGUI();
        opgave11_2Oplossing.show();
    }

    private void createGUI() {
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        Container window = getContentPane();
        window.setLayout(new FlowLayout());

        feetLbl = new JLabel();
        feetLbl.setText("Aantal feet:");
        window.add(feetLbl);
        
        feetTxt = new JTextField(8);
        window.add(feetTxt);
        
        inchesLbl = new JLabel();
        inchesLbl.setText("Aantal inches:");
        window.add(inchesLbl);
        
        inchesTxt = new JTextField(8);
        window.add(inchesTxt);
                   
        berekenBut = new JButton("Bereken");
        window.add(berekenBut);
        berekenBut.addActionListener(this);

        centimeterLbl = new JLabel();
        centimeterLbl.setText("aantal centimeters:");
        window.add(centimeterLbl);
        
        centimeterTxt = new JTextField(8);
        window.add(centimeterTxt);
        
    }
    
    
    
    public void actionPerformed(ActionEvent event) {
        
        
        Double inches = Double.parseDouble(feetTxt.getText())*12 + Double.parseDouble(inchesTxt.getText());
        centimeters = inches * 2.54;
        DecimalFormat formatter = new DecimalFormat("##.##");
        centimeterTxt.setText(formatter.format(centimeters));
        
    }
    
    
   
}

