package net.h4ckx0r.vista.panels;

import net.h4ckx0r.modelo.Curso;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class PanelCursos extends JPanel {

	private static final long serialVersionUID = 1L;

	private Curso cursoActual;
	private JTextField tfDescripcion;

	/**
	 * Create the panel.
	 */
	public PanelCursos() {
		GridBagLayout gridBagLayout = new GridBagLayout();
		gridBagLayout.columnWidths = new int[]{0, 0, 0};
		gridBagLayout.rowHeights = new int[]{0, 0, 0, 0};
		gridBagLayout.columnWeights = new double[]{0.2, 1.0, Double.MIN_VALUE};
		gridBagLayout.rowWeights = new double[]{0.0, 0.0, 1.0, Double.MIN_VALUE};
		setLayout(gridBagLayout);
		
		JLabel lblNewLabel = new JLabel("Descripción:");
		GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
		gbc_lblNewLabel.insets = new Insets(0, 0, 5, 5);
		gbc_lblNewLabel.anchor = GridBagConstraints.EAST;
		gbc_lblNewLabel.gridx = 0;
		gbc_lblNewLabel.gridy = 0;
		add(lblNewLabel, gbc_lblNewLabel);
		
		tfDescripcion = new JTextField();
		GridBagConstraints gbc_textField = new GridBagConstraints();
		gbc_textField.insets = new Insets(0, 0, 5, 0);
		gbc_textField.fill = GridBagConstraints.HORIZONTAL;
		gbc_textField.gridx = 1;
		gbc_textField.gridy = 0;
		add(tfDescripcion, gbc_textField);
		tfDescripcion.setColumns(10);
	}

	public Curso getCursoActual() {
		cursoActual.setDescripcion(tfDescripcion.getText());
		return cursoActual;
	}

	public void setCursoActual(Curso cursoActual) {
		this.cursoActual = cursoActual;
		tfDescripcion.setText(cursoActual.getDescripcion());
	}

}
