package etf.si.projekat.data_vision;

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;

import java.awt.Button;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

import javax.swing.JTextField;
import java.util.logging.Logger;
import java.util.logging.Level;
import ba.unsa.etf.si.beans.DeviceName;
import ba.unsa.etf.si.beans.DeviceType;
import ba.unsa.etf.si.hibernate_klase.HibernateDeviceName;
import ba.unsa.etf.si.hibernate_klase.HibernateDeviceType;

import java.awt.Color;

public class AddDevice extends JFrame { //extends JFrame
	private static final Logger logger = Logger.getLogger(AddDevice.class.getName());

	private JPanel contentPane;
	private JTextField textField_2;
	private JTextField textField_3;
	

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					AddDevice frame = new AddDevice();
					frame.setVisible(true);
				} catch (Exception e) {
					
					logger.log( Level.SEVERE, "context", e );
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public AddDevice() {
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JLabel lblGraphType = new JLabel("Device name");
		lblGraphType.setBounds(98, 84, 73, 14);
		contentPane.add(lblGraphType);
		
		JLabel lblTimeIntervalFrom = new JLabel("Device type");
		lblTimeIntervalFrom.setBounds(98, 139, 111, 14);
		contentPane.add(lblTimeIntervalFrom);
		
		Button button = new Button("Continue");
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				
				if(textField_2.getText().isEmpty() || textField_3.getText().isEmpty() || textField_2.getText().matches("\\s+")|| textField_3.getText().matches("\\s+")){
					JOptionPane.showMessageDialog(null, "Nisu sva polja ispunjena", "AlertBox", JOptionPane.WARNING_MESSAGE);
				}
				else{
				DeviceName dn = new DeviceName();
				dn.setName(textField_2.getText());
				HibernateDeviceName hdn = new HibernateDeviceName();
				hdn.addDeviceName(dn);
				
				DeviceType dt = new DeviceType();
			
				dt.setType(textField_3.getText());
				HibernateDeviceType hdt = new HibernateDeviceType();
				hdt.addDeviceType(dt);
				
				JOptionPane.showMessageDialog(null, "New device added.", "InfoBox", JOptionPane.INFORMATION_MESSAGE);
				
				dispose();
				}
			}
		});
		button.setBounds(354, 230, 70, 22);
		contentPane.add(button);
		
		Button button_1 = new Button("Cancel");
		button_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				dispose();
			}
		});
		button_1.setBounds(278, 230, 70, 22);
		contentPane.add(button_1);
	
		JPanel panel = new JPanel();
		panel.setBackground(new Color(0, 191, 255));
		panel.setBounds(0, 0, 434, 36);
		contentPane.add(panel);
		
		JPanel panel_1 = new JPanel();
		panel_1.setBackground(new Color(0, 191, 255));
		panel_1.setBounds(0, 218, 434, 54);
		contentPane.add(panel_1);
		
		textField_2 = new JTextField();
		textField_2.setBounds(181, 81, 86, 20);
		contentPane.add(textField_2);
		textField_2.setColumns(10);
		
		textField_3 = new JTextField();
		textField_3.setBounds(180, 136, 86, 20);
		contentPane.add(textField_3);
		textField_3.setColumns(10);
		
	}
}

@@ -857,17 +857,16 @@
 extField
-_
 2;%0D%0A%09pri
@@ -890,17 +890,16 @@
 extField
-_
 3;%0D%0A%09%0D%0A%0D
@@ -1940,33 +1940,32 @@
 %09%09%09%09if(textField
-_
 2.getText().isEm
@@ -1974,33 +1974,32 @@
 y() %7C%7C textField
-_
 3.getText().isEm
@@ -2008,33 +2008,32 @@
 y() %7C%7C textField
-_
 2.getText().matc
@@ -2047,33 +2047,32 @@
 s+%22)%7C%7C textField
-_
 3.getText().matc
@@ -2279,17 +2279,16 @@
 extField
-_
 2.getTex
@@ -2454,17 +2454,16 @@
 extField
-_
 3.getTex
@@ -2796,17 +2796,16 @@
 n button
-_
 1 = new 
@@ -2831,17 +2831,16 @@
 %09%09button
-_
 1.addAct
@@ -2961,17 +2961,16 @@
 %09%09button
-_
 1.setBou
@@ -3017,17 +3017,16 @@
 d(button
-_
 1);%0D%0A%09%0D%0A
@@ -3185,17 +3185,16 @@
 el panel
-_
 1 = new 
@@ -3207,25 +3207,24 @@
 ();%0D%0A%09%09panel
-_
 1.setBackgro
@@ -3260,17 +3260,16 @@
 %0A%09%09panel
-_
 1.setBou
@@ -3314,17 +3314,16 @@
 dd(panel
-_
 1);%0D%0A%09%09%0D
@@ -3334,17 +3334,16 @@
 extField
-_
 2 = new 
@@ -3364,25 +3364,24 @@
 %0A%09%09textField
-_
 2.setBounds(
@@ -3426,17 +3426,16 @@
 extField
-_
 2);%0D%0A%09%09t
@@ -3442,17 +3442,16 @@
 extField
-_
 2.setCol
@@ -3476,17 +3476,16 @@
 extField
-_
 3 = new 
@@ -3506,25 +3506,24 @@
 %0A%09%09textField
-_
 3.setBounds(
@@ -3569,17 +3569,16 @@
 extField
-_
 3);%0D%0A%09%09t
@@ -3585,17 +3585,16 @@
 extField
-_
 3.setCol

Update AddDevice.java