/**
 * 
 */
package gui.java7.principal;

import static java.awt.BorderLayout.CENTER;
import static java.lang.System.exit;
import static java.lang.System.out;
import static javax.swing.JOptionPane.INFORMATION_MESSAGE;
import static javax.swing.JOptionPane.showMessageDialog;
import gui.dialogo.captura.DialogoCaptura;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

/**
 * @author ˇ
 *
 */
public class Principal extends JFrame {
	public Principal() {
		super("Pantalla principal");
		initComponetes();
	}

	private void initComponetes() {
		setLayout(new BorderLayout());
		centrado = new JPanel();
		centrado.setLayout(new FlowLayout());
		ver = new JButton("Veer");
		cerrar = new JButton("Cerrar");
		crear = new JButton("Crear");
		dialogo = new JButton("Capturar Datos");
		ver.addActionListener(new AccionOyente());
		crear.addActionListener(new AccionOyente());
		dialogo.addActionListener(new AccionOyente());
		cerrar.addActionListener(new AccionOyente());
		centrado.add(ver);
		centrado.add(crear);
		centrado.add(dialogo);
		centrado.add(cerrar);
		add(centrado, CENTER);
		setSize(600, 400);
		setLocationRelativeTo(null);
		setDefaultCloseOperation(DISPOSE_ON_CLOSE);
	}

	/***
	 * 
	 * @author ?
	 * *
	 * * clase anonima para las acciones de los botones
	 */
	private class AccionOyente implements ActionListener {

		@Override
		public void actionPerformed(ActionEvent e) {
			// TODO Auto-generated method stub
			if (e.getSource() == ver) {
				out.printf("%s%n", "No tengo función en este momento");
			}
			if (e.getSource() == crear) {
				out.printf("%s%n", "No tengo función en este momento");
			}
			if (e.getSource() == dialogo) {
				cargaDialogo();
			}
			if (e.getSource() == cerrar) {
				showMessageDialog(null, "Cerrando programita", "Mensaje",
						INFORMATION_MESSAGE);
				exit(0);
			}

		}

	}

	private void cargaDialogo() {
		captura = new DialogoCaptura(this, "Inicia captura", true);
		captura.setSize(650, 100);
		captura.setLocationRelativeTo(null);
		captura.setVisible(true);
		captura.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
	}

	/**
	 * 
	 */
	private static final long serialVersionUID = -7600426127117592872L;
	private JPanel centrado;
	private JButton dialogo, crear, cerrar, ver;
	private DialogoCaptura captura;

}
