/**
 * Това приложение е написано от мен днес.
 * Това е втора бета версия.
 * Намира средната скорост на влак, който тръгва
 * от гара и за време 40s достига средна скорост 
 * 36 km/h. Движението е равноускорително.
 */

package edu.school;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class Physics extends JFrame {

	private JPanel contentPane;
	private JTextField textField;
	private JTextField textField_1;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Physics frame = new Physics();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public Physics() {
		setTitle("Physics");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 273, 146);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);

		JLabel lblNewLabel = new JLabel("V");
		lblNewLabel.setBounds(30, 35, 22, 14);
		contentPane.add(lblNewLabel);

		textField = new JTextField();
		textField.setBounds(43, 32, 86, 20);
		contentPane.add(textField);
		textField.setColumns(10);

		JLabel lblNewLabel_1 = new JLabel("t");
		lblNewLabel_1.setBounds(30, 73, 46, 14);
		contentPane.add(lblNewLabel_1);

		textField_1 = new JTextField();
		textField_1.setBounds(40, 70, 86, 20);
		contentPane.add(textField_1);
		textField_1.setColumns(10);

		JLabel lblNewLabel_2 = new JLabel("New label");
		lblNewLabel_2.setBounds(168, 73, 46, 14);
		contentPane.add(lblNewLabel_2);

		JButton btnNewButton = new JButton("\u0421\u041C\u0415\u0422\u041D\u0418");

btnNewButton.addActionListener(new ActionListener() {
	public void actionPerformed(ActionEvent arg0)
	 {	int V,t,a;
	 V=Integer.parseInt(textField.getText());
	 t=Integer.parseInt(textField_1.getText());
	 a=V/t;
    lblNewLabel_2.setText(Integer.toString(a));}});

		btnNewButton.setBounds(158, 31, 89, 23);
		contentPane.add(btnNewButton);
	}
}
