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

public class Opgave11_1Oplossing extends JFrame implements ActionListener {

    private JButton kostBut;
    private JTextField urenTxt,minutenTxt,secondenTxt,kostTxt;
    private JLabel urenLbl,minutenLbl,secondenLbl,kostLbl;
    private double kost;

    public static void main(String[] args) {
        Opgave11_1Oplossing opgave11_1 = new Opgave11_1Oplossing();
        opgave11_1.setSize(120,300);
        opgave11_1.createGUI();
        opgave11_1.show();
    }

    private void createGUI() {
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        Container window = getContentPane();
        window.setLayout(new FlowLayout());

        urenLbl = new JLabel();
        urenLbl.setText("Aantal uren:");
        window.add(urenLbl);
        
        urenTxt = new JTextField(8);
        window.add(urenTxt);
        
        minutenLbl = new JLabel();
        minutenLbl.setText("Aantal minuten:");
        window.add(minutenLbl);
        
        minutenTxt = new JTextField(8);
        window.add(minutenTxt);
        
        secondenLbl = new JLabel();
        secondenLbl.setText("Aantal seconden:");
        window.add(secondenLbl);
        
        secondenTxt = new JTextField(8);
        window.add(secondenTxt);
        
        kostBut = new JButton("Kostprijs");
        window.add(kostBut);
        kostBut.addActionListener(this);

        kostLbl = new JLabel();
        kostLbl.setText("Kostprijs gesprek:");
        window.add(kostLbl);
        
        kostTxt = new JTextField(8);
        window.add(kostTxt);
        
    }
    
    
    
    public void actionPerformed(ActionEvent event) {
        
        
        Double minuten = Double.parseDouble(urenTxt.getText())*60 + Double.parseDouble(minutenTxt.getText()) + (Double.parseDouble(secondenTxt.getText())/60);
        kost = minuten * 0.1;
        DecimalFormat formatter = new DecimalFormat("##.##");
        kostTxt.setText(formatter.format(kost));
        
    }
    
    
   
}

