Métodos para gestión del panel de Personas
This commit is contained in:
@@ -1,21 +1,27 @@
|
||||
package net.h4ckx0r.vista.panels;
|
||||
|
||||
import net.h4ckx0r.modelo.Estudiante;
|
||||
import net.h4ckx0r.modelo.Persona;
|
||||
import net.h4ckx0r.modelo.Profesor;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.Insets;
|
||||
import java.awt.BorderLayout;
|
||||
|
||||
public class PanelPersona extends JPanel {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private JTextField textField;
|
||||
private JTextField textField_1;
|
||||
private JTextField textField_2;
|
||||
private JTextField textField_3;
|
||||
private JTextField textField_4;
|
||||
private JTextField textField_5;
|
||||
private JTextField textField_6;
|
||||
|
||||
private Persona personaActual;
|
||||
|
||||
private JTextField tfNombre;
|
||||
private JTextField tfApellido1;
|
||||
private JTextField tfApellido2;
|
||||
private JTextField tfDNI;
|
||||
private JTextField tfDireccion;
|
||||
private JTextField tfEmail;
|
||||
private JTextField tfTelefono;
|
||||
|
||||
/**
|
||||
* Create the panel.
|
||||
@@ -36,14 +42,14 @@ public class PanelPersona extends JPanel {
|
||||
gbc_lblNewLabel.gridy = 0;
|
||||
add(lblNewLabel, gbc_lblNewLabel);
|
||||
|
||||
textField = new JTextField();
|
||||
tfNombre = 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(textField, gbc_textField);
|
||||
textField.setColumns(10);
|
||||
add(tfNombre, gbc_textField);
|
||||
tfNombre.setColumns(10);
|
||||
|
||||
JLabel lblNewLabel_1 = new JLabel("Primer Apellido:");
|
||||
GridBagConstraints gbc_lblNewLabel_1 = new GridBagConstraints();
|
||||
@@ -53,14 +59,14 @@ public class PanelPersona extends JPanel {
|
||||
gbc_lblNewLabel_1.gridy = 1;
|
||||
add(lblNewLabel_1, gbc_lblNewLabel_1);
|
||||
|
||||
textField_1 = new JTextField();
|
||||
tfApellido1 = new JTextField();
|
||||
GridBagConstraints gbc_textField_1 = new GridBagConstraints();
|
||||
gbc_textField_1.insets = new Insets(0, 0, 5, 0);
|
||||
gbc_textField_1.fill = GridBagConstraints.HORIZONTAL;
|
||||
gbc_textField_1.gridx = 1;
|
||||
gbc_textField_1.gridy = 1;
|
||||
add(textField_1, gbc_textField_1);
|
||||
textField_1.setColumns(10);
|
||||
add(tfApellido1, gbc_textField_1);
|
||||
tfApellido1.setColumns(10);
|
||||
|
||||
JLabel lblNewLabel_2 = new JLabel("Segundo Apellido:");
|
||||
GridBagConstraints gbc_lblNewLabel_2 = new GridBagConstraints();
|
||||
@@ -70,14 +76,14 @@ public class PanelPersona extends JPanel {
|
||||
gbc_lblNewLabel_2.gridy = 2;
|
||||
add(lblNewLabel_2, gbc_lblNewLabel_2);
|
||||
|
||||
textField_2 = new JTextField();
|
||||
tfApellido2 = new JTextField();
|
||||
GridBagConstraints gbc_textField_2 = new GridBagConstraints();
|
||||
gbc_textField_2.insets = new Insets(0, 0, 5, 0);
|
||||
gbc_textField_2.fill = GridBagConstraints.HORIZONTAL;
|
||||
gbc_textField_2.gridx = 1;
|
||||
gbc_textField_2.gridy = 2;
|
||||
add(textField_2, gbc_textField_2);
|
||||
textField_2.setColumns(10);
|
||||
add(tfApellido2, gbc_textField_2);
|
||||
tfApellido2.setColumns(10);
|
||||
|
||||
JLabel lblNewLabel_3 = new JLabel("DNI:");
|
||||
GridBagConstraints gbc_lblNewLabel_3 = new GridBagConstraints();
|
||||
@@ -87,14 +93,14 @@ public class PanelPersona extends JPanel {
|
||||
gbc_lblNewLabel_3.gridy = 3;
|
||||
add(lblNewLabel_3, gbc_lblNewLabel_3);
|
||||
|
||||
textField_3 = new JTextField();
|
||||
tfDNI = new JTextField();
|
||||
GridBagConstraints gbc_textField_3 = new GridBagConstraints();
|
||||
gbc_textField_3.insets = new Insets(0, 0, 5, 0);
|
||||
gbc_textField_3.fill = GridBagConstraints.HORIZONTAL;
|
||||
gbc_textField_3.gridx = 1;
|
||||
gbc_textField_3.gridy = 3;
|
||||
add(textField_3, gbc_textField_3);
|
||||
textField_3.setColumns(10);
|
||||
add(tfDNI, gbc_textField_3);
|
||||
tfDNI.setColumns(10);
|
||||
|
||||
JLabel lblNewLabel_4 = new JLabel("Dirección:");
|
||||
GridBagConstraints gbc_lblNewLabel_4 = new GridBagConstraints();
|
||||
@@ -104,14 +110,14 @@ public class PanelPersona extends JPanel {
|
||||
gbc_lblNewLabel_4.gridy = 4;
|
||||
add(lblNewLabel_4, gbc_lblNewLabel_4);
|
||||
|
||||
textField_4 = new JTextField();
|
||||
tfDireccion = new JTextField();
|
||||
GridBagConstraints gbc_textField_4 = new GridBagConstraints();
|
||||
gbc_textField_4.insets = new Insets(0, 0, 5, 0);
|
||||
gbc_textField_4.fill = GridBagConstraints.HORIZONTAL;
|
||||
gbc_textField_4.gridx = 1;
|
||||
gbc_textField_4.gridy = 4;
|
||||
add(textField_4, gbc_textField_4);
|
||||
textField_4.setColumns(10);
|
||||
add(tfDireccion, gbc_textField_4);
|
||||
tfDireccion.setColumns(10);
|
||||
|
||||
JLabel lblNewLabel_5 = new JLabel("Email:");
|
||||
GridBagConstraints gbc_lblNewLabel_5 = new GridBagConstraints();
|
||||
@@ -121,14 +127,14 @@ public class PanelPersona extends JPanel {
|
||||
gbc_lblNewLabel_5.gridy = 5;
|
||||
add(lblNewLabel_5, gbc_lblNewLabel_5);
|
||||
|
||||
textField_5 = new JTextField();
|
||||
tfEmail = new JTextField();
|
||||
GridBagConstraints gbc_textField_5 = new GridBagConstraints();
|
||||
gbc_textField_5.insets = new Insets(0, 0, 5, 0);
|
||||
gbc_textField_5.fill = GridBagConstraints.HORIZONTAL;
|
||||
gbc_textField_5.gridx = 1;
|
||||
gbc_textField_5.gridy = 5;
|
||||
add(textField_5, gbc_textField_5);
|
||||
textField_5.setColumns(10);
|
||||
add(tfEmail, gbc_textField_5);
|
||||
tfEmail.setColumns(10);
|
||||
|
||||
JLabel lblNewLabel_6 = new JLabel("Teléfono");
|
||||
GridBagConstraints gbc_lblNewLabel_6 = new GridBagConstraints();
|
||||
@@ -138,15 +144,52 @@ public class PanelPersona extends JPanel {
|
||||
gbc_lblNewLabel_6.gridy = 6;
|
||||
add(lblNewLabel_6, gbc_lblNewLabel_6);
|
||||
|
||||
textField_6 = new JTextField();
|
||||
tfTelefono = new JTextField();
|
||||
GridBagConstraints gbc_textField_6 = new GridBagConstraints();
|
||||
gbc_textField_6.insets = new Insets(0, 0, 5, 0);
|
||||
gbc_textField_6.fill = GridBagConstraints.HORIZONTAL;
|
||||
gbc_textField_6.gridx = 1;
|
||||
gbc_textField_6.gridy = 6;
|
||||
add(textField_6, gbc_textField_6);
|
||||
textField_6.setColumns(10);
|
||||
add(tfTelefono, gbc_textField_6);
|
||||
tfTelefono.setColumns(10);
|
||||
|
||||
}
|
||||
|
||||
private void setPersona(Persona persona) {
|
||||
tfNombre.setText(persona.getNombre());
|
||||
tfApellido1.setText(persona.getApellido1());
|
||||
tfApellido2.setText(persona.getApellido2());
|
||||
tfDNI.setText(persona.getDni());
|
||||
tfDireccion.setText(persona.getDireccion());
|
||||
tfEmail.setText(persona.getEmail());
|
||||
tfTelefono.setText(persona.getTelefono());
|
||||
}
|
||||
|
||||
private Persona getPersona() {
|
||||
personaActual.setNombre(tfNombre.getText());
|
||||
personaActual.setApellido1(tfApellido1.getText());
|
||||
personaActual.setApellido2(tfApellido2.getText());
|
||||
personaActual.setDni(tfDNI.getText());
|
||||
personaActual.setDireccion(tfDireccion.getText());
|
||||
personaActual.setEmail(tfEmail.getText());
|
||||
personaActual.setTelefono(tfTelefono.getText());
|
||||
return personaActual;
|
||||
}
|
||||
|
||||
public void setEstudiante(Estudiante estudiante) {
|
||||
setPersona(estudiante);
|
||||
}
|
||||
|
||||
public Estudiante getEstudiante() {
|
||||
return (Estudiante) getPersona();
|
||||
}
|
||||
|
||||
public void setProfesor(Profesor profesor) {
|
||||
setPersona(profesor);
|
||||
}
|
||||
|
||||
public Profesor getProfesor() {
|
||||
return (Profesor) getPersona();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user