package tutorialJava.capitulo9_AWT_SWING.ejemplos.ejemplo02_CentroEducativo;

import javax.swing.JPanel;
import java.awt.BorderLayout;
import javax.swing.JLabel;
import java.awt.GridBagLayout;
import javax.swing.JToolBar;

import tutorialJava.modelosBasesDeDatosComunesJPA.evaluacionCentroEducativo.Estudiante;

import java.awt.GridBagConstraints;
import java.awt.Insets;
import java.awt.Font;
import javax.swing.JButton;
import javax.swing.ImageIcon;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class JPanelEstudiante extends JPanel {

	private static final long serialVersionUID = 1L;
	private JPanelDatosPersonales panelDatos = new JPanelDatosPersonales();

	/**
	 * Create the panel.
	 */
	public JPanelEstudiante() {
		GridBagLayout gridBagLayout = new GridBagLayout();
		gridBagLayout.columnWidths = new int[]{0, 0};
		gridBagLayout.rowHeights = new int[]{0, 0, 0};
		gridBagLayout.columnWeights = new double[]{0.0, Double.MIN_VALUE};
		gridBagLayout.rowWeights = new double[]{0.0, 0.0, Double.MIN_VALUE};
		setLayout(gridBagLayout);
		
		JToolBar toolBar = new JToolBar();
		GridBagConstraints gbc_toolBar = new GridBagConstraints();
		gbc_toolBar.insets = new Insets(0, 0, 5, 0);
		gbc_toolBar.gridx = 0;
		gbc_toolBar.gridy = 0;
		add(toolBar, gbc_toolBar);
		
		JButton btnNewButton = new JButton("");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
//				Estudiante e = ControladorEstudiante.findFirst();
//				panelDatos.setId(e.getId());
//				panelDatos.setNombre(e.getNombre());
			}
		});
		btnNewButton.setIcon(new ImageIcon(JPanelEstudiante.class.getResource("/tutorialJava/capitulo9_AWT_SWING/res/gotostart.png")));
		toolBar.add(btnNewButton);
		
		JLabel lblNewLabel = new JLabel("Gestión de estudiantes");
		lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 14));
		GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
		gbc_lblNewLabel.gridx = 0;
		gbc_lblNewLabel.gridy = 1;
		add(lblNewLabel, gbc_lblNewLabel);
		
		GridBagConstraints gbc_PanelDatosPersonales = new GridBagConstraints();
		gbc_PanelDatosPersonales.gridx = 0;
		gbc_PanelDatosPersonales.gridy = 2;
		add(panelDatos, gbc_PanelDatosPersonales);

		
		panelDatos.setRunnableNavegarPrimerRegistro(new Runnable() {
			public void run() {
//				Estudiante e = ControladorEstudiante.findFirst();
//				panelDatos.setId(e.getId());
//				panelDatos.setNombre(e.getNombre());
			}
		});
	}

	
//	private void cargarEstudianteEnPantalla(Estudiante e) {
//		this.panelDatos.setId(e.getId());
//	}
}
