/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Interfaz;
/**
*
* @author ANASS
*/
import Controladores.ControladorUsuario;
import GestorUsuarios.Usuario;
import javax.swing.*;
import java.awt.*;
import java.awt.AWTEvent;
import java.awt.image.*;
import java.lang.*;
import java.util.Date;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
public class InterfazUsuario extends javax.swing.JPanel {
private static InterfazUsuario Instancia = null;
ControladorUsuario controlador;
Boolean editable ;
Boolean registro_valido;
Boolean esGestor;
/**
* Creates new form InterfazUsuario
*/
public InterfazUsuario() {
initComponents();
controlador = ControladorUsuario.getInstancia();
}
public static InterfazUsuario getInstancia() {
if(Instancia == null){
Instancia = new InterfazUsuario();
}
return Instancia;
}
public Object clone() throws CloneNotSupportedException {
throw new CloneNotSupportedException();
}
public Boolean get_Editable(){
return editable;
}
public void set_Editable(Boolean estado) {
jTextFieldBuscarUsu.setEditable(estado);
TextBuscaNom.setEditable(estado);
TextBuscaApelli.setEditable(estado);
TextBuscaDNI.setEditable(estado);
TextEmail.setEditable(estado);
PasswordFieldUsu.setEditable(estado);
PasswordConfir.setEditable(estado);
RadioButtonEntrena.setEnabled(estado);
jRadioButtonGestor.setEnabled(estado);
TextFieldLogin.setEditable(estado);
RadioButtonGestor.setEnabled(estado);
RadioButtonEntrenador.setEnabled(estado);
editable = estado;
}
public Boolean get_RegValido() {
return registro_valido;
}
public void set_RegValido(Boolean valor) {
registro_valido = valor;
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jPanel3 = new javax.swing.JPanel();
jButtonConsultarUsu = new javax.swing.JButton();
jButtonAltaNuevoUsu = new javax.swing.JButton();
Titulo_JPanel1 = new javax.swing.JLabel();
IconoFCB1 = new javax.swing.JLabel();
jPanel5 = new javax.swing.JPanel();
jLabel13 = new javax.swing.JLabel();
TextNombre = new javax.swing.JTextField();
jLabel14 = new javax.swing.JLabel();
TextApelli = new javax.swing.JTextField();
TextDNI = new javax.swing.JTextField();
jLabel16 = new javax.swing.JLabel();
RadioButtonEntrena = new javax.swing.JRadioButton();
jRadioButtonGestor = new javax.swing.JRadioButton();
jButtonConfirmarAlta = new javax.swing.JButton();
jButtonVolverAlta = new javax.swing.JButton();
TextFieldCorreo = new javax.swing.JTextField();
jLabelEmailAlta = new javax.swing.JLabel();
TextAltaLogin = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
jLabelAltaContrasena = new javax.swing.JLabel();
PasswordFieldContra = new javax.swing.JPasswordField();
Titulo_JPanel = new javax.swing.JLabel();
IconoFCB = new javax.swing.JLabel();
jPanel1 = new javax.swing.JPanel();
jButtonBorrar = new javax.swing.JButton();
jButtonModificar = new javax.swing.JButton();
jButtonVolver = new javax.swing.JButton();
jTextFieldBuscarUsu = new javax.swing.JTextField();
jLabel11 = new javax.swing.JLabel();
jButtonGuardar = new javax.swing.JButton();
TextBuscaNom = new javax.swing.JTextField();
jLabel6 = new javax.swing.JLabel();
TextBuscaApelli = new javax.swing.JTextField();
jLabel7 = new javax.swing.JLabel();
TextBuscaDNI = new javax.swing.JTextField();
jLabel8 = new javax.swing.JLabel();
TextEmail = new javax.swing.JTextField();
jLabelEmail = new javax.swing.JLabel();
PasswordFieldUsu = new javax.swing.JPasswordField();
jLabel12 = new javax.swing.JLabel();
jLabelNuevaContra = new javax.swing.JLabel();
TextFieldLogin = new javax.swing.JTextField();
jLabelLogin = new javax.swing.JLabel();
RadioButtonGestor = new javax.swing.JRadioButton();
RadioButtonEntrenador = new javax.swing.JRadioButton();
PasswordConfir = new javax.swing.JPasswordField();
Titulo_JPanel2 = new javax.swing.JLabel();
IconoFCB2 = new javax.swing.JLabel();
jButtonConsultarUsu.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jButtonConsultarUsu.setText("Consultar usuarios");
jButtonConsultarUsu.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonConsultarUsuActionPerformed(evt);
}
});
jButtonAltaNuevoUsu.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jButtonAltaNuevoUsu.setText("Alta nuevo usuario");
jButtonAltaNuevoUsu.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonAltaNuevoUsuActionPerformed(evt);
}
});
Titulo_JPanel1.setFont(new java.awt.Font("Andalus", 1, 24)); // NOI18N
Titulo_JPanel1.setText("FUNDACION CLUB BALONCESTO GRANADA");
IconoFCB1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Recursos/FCBGranada2.PNG"))); // NOI18N
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGap(66, 66, 66)
.addComponent(jButtonAltaNuevoUsu)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButtonConsultarUsu)
.addGap(45, 45, 45))
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addComponent(IconoFCB1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(Titulo_JPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 497, javax.swing.GroupLayout.PREFERRED_SIZE))
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(Titulo_JPanel1)
.addComponent(IconoFCB1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 142, Short.MAX_VALUE)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButtonAltaNuevoUsu, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButtonConsultarUsu, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(31, 31, 31))
);
jPanel5.setVisible(false);
jLabel13.setText("Nombre");
jLabel14.setText("Apellidos");
TextApelli.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
TextApelliActionPerformed(evt);
}
});
TextDNI.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
TextDNIActionPerformed(evt);
}
});
jLabel16.setText("DNI");
RadioButtonEntrena.setText("Entrenador");
RadioButtonEntrena.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
RadioButtonEntrenaActionPerformed(evt);
}
});
jRadioButtonGestor.setText("Gestor");
jRadioButtonGestor.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButtonGestorActionPerformed(evt);
}
});
jButtonConfirmarAlta.setText("Confirmar");
jButtonConfirmarAlta.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonConfirmarAltaActionPerformed(evt);
}
});
jButtonVolverAlta.setText("Volver");
jButtonVolverAlta.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonVolverAltaActionPerformed(evt);
}
});
TextFieldCorreo.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
TextFieldCorreoActionPerformed(evt);
}
});
jLabelEmailAlta.setText("Email");
jLabelEmailAlta.setVisible(true);
jLabel3.setText("Login");
jLabelAltaContrasena.setText("Contraseña");
PasswordFieldContra.setText("jPasswordField1");
Titulo_JPanel.setFont(new java.awt.Font("Andalus", 1, 24)); // NOI18N
Titulo_JPanel.setText("FUNDACION CLUB BALONCESTO GRANADA");
IconoFCB.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Recursos/FCBGranada2.PNG"))); // NOI18N
javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
jPanel5.setLayout(jPanel5Layout);
jPanel5Layout.setHorizontalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabelEmailAlta, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel13, javax.swing.GroupLayout.Alignment.TRAILING))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addComponent(TextAltaLogin, javax.swing.GroupLayout.PREFERRED_SIZE, 144, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(56, 56, 56)
.addComponent(jLabelAltaContrasena)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(PasswordFieldContra, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(jPanel5Layout.createSequentialGroup()
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(TextNombre, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(TextFieldCorreo, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
.addComponent(RadioButtonEntrena)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jRadioButtonGestor))
.addGroup(jPanel5Layout.createSequentialGroup()
.addComponent(jLabel14)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(TextApelli, javax.swing.GroupLayout.PREFERRED_SIZE, 152, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel16))))
.addGroup(jPanel5Layout.createSequentialGroup()
.addGap(12, 12, 12)
.addComponent(jButtonVolverAlta)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jButtonConfirmarAlta)
.addComponent(TextDNI, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(IconoFCB)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(Titulo_JPanel)
.addGap(73, 73, 73))
);
jPanel5Layout.setVerticalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addGap(31, 31, 31)
.addComponent(Titulo_JPanel))
.addComponent(IconoFCB))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 27, Short.MAX_VALUE)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(TextNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel13)
.addComponent(TextApelli, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel14)
.addComponent(TextDNI, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel16))
.addGap(18, 18, 18)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabelEmailAlta)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(RadioButtonEntrena)
.addComponent(jRadioButtonGestor)
.addComponent(TextFieldCorreo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(18, 18, 18)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(TextAltaLogin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3)
.addComponent(jLabelAltaContrasena)
.addComponent(PasswordFieldContra, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(68, 68, 68)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButtonVolverAlta)
.addComponent(jButtonConfirmarAlta))
.addGap(31, 31, 31))
);
jPanel1.setVisible(false);
jButtonBorrar.setText("Borrar");
jButtonBorrar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonBorrarActionPerformed(evt);
}
});
jButtonModificar.setText("Modificar");
jButtonModificar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonModificarActionPerformed(evt);
}
});
jButtonVolver.setText("Volver");
jButtonVolver.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonVolverActionPerformed(evt);
}
});
jTextFieldBuscarUsu.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextFieldBuscarUsuActionPerformed(evt);
}
});
jLabel11.setText("Buscar usuario");
jButtonGuardar.setText("Guardar");
jButtonGuardar.setVisible(false);
jButtonGuardar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonGuardarActionPerformed(evt);
}
});
jLabel6.setText(" Nombre ");
jLabel7.setText("Apellidos");
jLabel8.setText("DNI");
jLabelEmail.setText("Email");
PasswordFieldUsu.setText("jPasswordField1");
jLabel12.setText("Contraseña");
jLabelNuevaContra.setText("Confirmar Nueva Contraseña");
jLabelNuevaContra.setVisible(false);
TextFieldLogin.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
TextFieldLoginActionPerformed(evt);
}
});
jLabelLogin.setText("Login");
RadioButtonGestor.setText("Gestor");
RadioButtonGestor.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
RadioButtonGestorActionPerformed(evt);
}
});
RadioButtonEntrenador.setText("Entrenador");
RadioButtonEntrenador.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
RadioButtonEntrenadorActionPerformed(evt);
}
});
PasswordConfir.setText("jPasswordField1");
Titulo_JPanel2.setFont(new java.awt.Font("Andalus", 1, 24)); // NOI18N
Titulo_JPanel2.setText("FUNDACION CLUB BALONCESTO GRANADA");
IconoFCB2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Recursos/FCBGranada2.PNG"))); // NOI18N
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addComponent(jButtonVolver)
.addGap(160, 160, 160)
.addComponent(jButtonModificar)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButtonGuardar)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButtonBorrar)
.addGap(28, 28, 28))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel12)
.addComponent(jLabelLogin, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabelEmail, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel8, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel7, javax.swing.GroupLayout.Alignment.TRAILING))
.addComponent(jLabel6)
.addComponent(jLabelNuevaContra))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(PasswordFieldUsu, javax.swing.GroupLayout.PREFERRED_SIZE, 159, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(PasswordConfir, javax.swing.GroupLayout.PREFERRED_SIZE, 159, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(TextFieldLogin, javax.swing.GroupLayout.PREFERRED_SIZE, 159, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(171, 171, 171))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(RadioButtonGestor)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(RadioButtonEntrenador))
.addComponent(TextEmail, javax.swing.GroupLayout.PREFERRED_SIZE, 159, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(TextBuscaDNI, javax.swing.GroupLayout.PREFERRED_SIZE, 159, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(TextBuscaApelli, javax.swing.GroupLayout.PREFERRED_SIZE, 159, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(TextBuscaNom, javax.swing.GroupLayout.PREFERRED_SIZE, 159, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())))))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(5, 5, 5)
.addComponent(IconoFCB2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addComponent(jLabel11)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextFieldBuscarUsu, javax.swing.GroupLayout.PREFERRED_SIZE, 174, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(27, 27, 27))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addComponent(Titulo_JPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 497, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(Titulo_JPanel2)
.addGap(39, 39, 39)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextFieldBuscarUsu, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel11)))
.addComponent(IconoFCB2))
.addGap(50, 50, 50)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel6)
.addComponent(TextBuscaNom, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(11, 11, 11)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(TextBuscaApelli, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(TextBuscaDNI, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(TextEmail, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabelEmail, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(TextFieldLogin, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabelLogin))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(RadioButtonGestor)
.addGap(10, 10, 10))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addComponent(RadioButtonEntrenador)
.addGap(18, 18, 18)))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(PasswordFieldUsu, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel12))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabelNuevaContra)
.addComponent(PasswordConfir, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 73, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButtonVolver)
.addComponent(jButtonGuardar)
.addComponent(jButtonModificar)
.addComponent(jButtonBorrar)))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addGap(19, 19, 19)
.addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 34, Short.MAX_VALUE)
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
}// </editor-fold>//GEN-END:initComponents
// Funcion que limpia los campos de texto y deseleciona los botones
public void limpiar() {
PasswordFieldUsu.setText("");
TextApelli.setText("");
TextBuscaApelli.setText("");
TextBuscaDNI.setText("");
TextBuscaNom.setText("");
TextDNI.setText("");
TextEmail.setText("");
TextNombre.setText("");
RadioButtonEntrena.setSelected(false);
TextFieldLogin.setText("");
jRadioButtonGestor.setSelected(false);
TextFieldCorreo.setText("");
TextAltaLogin.setText("");
PasswordFieldContra.setText("");
jTextFieldBuscarUsu.setText("");
PasswordConfir.setText("");
}
Boolean es_gestor(){
return esGestor;
}
public String [] CargarDatosFormulario() {
String [] datos = new String[7];
datos[0] = TextDNI.getText();
datos[1] = TextNombre.getText();
datos[2] = TextApelli.getText();
datos[3] = TextAltaLogin.getText();
datos[4] = new String(PasswordFieldContra.getPassword());
datos[5] = TextFieldCorreo.getText();
if(RadioButtonEntrena.isSelected()){
datos[6] = "E";
}
else {
datos[6] = "G";
}
return datos;
}
public Boolean marcarErrores() {
Boolean error = false;
if(TextNombre.getText().length()==0){
TextNombre.setBackground(Color.red);
error = true;
}
if(TextApelli.getText().length()==0){
TextApelli.setBackground(Color.red);
error = true;
}
if(TextDNI.getText().length()==0){
TextDNI.setBackground(Color.red);
error = true;
}
if(TextFieldCorreo.getText().length()==0){
TextFieldCorreo.setBackground(Color.red);
error =true;
}
if(TextAltaLogin.getText().length()==0){
TextAltaLogin.setBackground(Color.red);
error = true;
}
if(PasswordFieldContra.getPassword().toString().length()==0){
PasswordFieldContra.setBackground(Color.red);
error = true;
}
if(!RadioButtonEntrena.isSelected() && !jRadioButtonGestor.isSelected()) {
RadioButtonEntrena.setBackground(Color.red);
jRadioButtonGestor.setBackground(Color.red);
error = true;
}
if(RadioButtonEntrena.isSelected() && jRadioButtonGestor.isSelected()) {
RadioButtonEntrena.setBackground(Color.red);
jRadioButtonGestor.setBackground(Color.red);
error = true;
}
return error;
}
private void jButtonBorrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBorrarActionPerformed
int n = JOptionPane.showConfirmDialog(jPanel1, "Esta seguro querer borrar este usuario ?", "Wanrning !!!",JOptionPane.YES_NO_OPTION );
if(n==JOptionPane.YES_OPTION){
try {
String cadena = new String(TextBuscaDNI.getText().toString());
ControladorUsuario.getInstancia().deleteUsuario(cadena);
} catch (SQLException ex) {
Logger.getLogger(InterfazUsuario.class.getName()).log(Level.SEVERE, null, ex);
}
JOptionPane.showMessageDialog(jPanel1, "Usuario borrado del sistema ", "Message", 3);
}
limpiar();
jButtonGuardar.setVisible(false);
jButtonBorrar.setVisible(false);
jButtonModificar.setVisible(true);
set_Editable(false);
jTextFieldBuscarUsu.setVisible(true);
jTextFieldBuscarUsu.setEditable(true);
}//GEN-LAST:event_jButtonBorrarActionPerformed
private void jButtonConsultarUsuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonConsultarUsuActionPerformed
// TODO add your handling code here:
jPanel1.setVisible(true);
jPanel3.setVisible(false);
jPanel5.setVisible(false);
limpiar();
TextBuscaNom.setEditable(false);
TextBuscaApelli.setEditable(false);
TextBuscaDNI.setEditable(false);
TextEmail.setEditable(false);
TextFieldLogin.setEditable(false);
PasswordFieldUsu.setEditable(false);
PasswordFieldUsu.setVisible(false);
jLabelNuevaContra.setVisible(false);
jTextFieldBuscarUsu.setVisible(true);
jLabel11.setVisible(true);
jLabel12.setVisible(false);
jButtonModificar.setVisible(true);
jButtonBorrar.setVisible(false);
jButtonGuardar.setVisible(false);
jButtonVolver.setVisible(true);
PasswordConfir.setVisible(false);
RadioButtonGestor.setVisible(false);
RadioButtonEntrenador.setVisible(false);
}//GEN-LAST:event_jButtonConsultarUsuActionPerformed
private void jButtonAltaNuevoUsuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAltaNuevoUsuActionPerformed
// TODO add your handling code here:
jPanel1.setVisible(false);
jPanel3.setVisible(false);
jPanel5.setVisible(true);
RadioButtonEntrena.setEnabled(true);
jRadioButtonGestor.setEnabled(true);
// marcarErrores();
}//GEN-LAST:event_jButtonAltaNuevoUsuActionPerformed
private void jButtonVolverActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonVolverActionPerformed
// TODO add your handling code here:
jPanel1.setVisible(false);
jPanel5.setVisible(false);
jPanel3.setVisible(true);
}//GEN-LAST:event_jButtonVolverActionPerformed
private void jTextFieldBuscarUsuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldBuscarUsuActionPerformed
// TODO add your handling code here:
Usuario user = new Usuario();
jPanel5.setVisible(false);
jPanel3.setVisible(false);
PasswordFieldUsu.setVisible(false);
jLabel12.setVisible(false);
jLabelNuevaContra.setVisible(false);
jButtonGuardar.setVisible(false);
RadioButtonGestor.setVisible(true);
RadioButtonEntrenador.setVisible(true);
RadioButtonGestor.setEnabled(true);
RadioButtonEntrenador.setEnabled(true);
String cadena = jTextFieldBuscarUsu.getText();
//System.out.println("DNI = " + cadena);
try {
user = ControladorUsuario.getInstancia().getUsuario(cadena);
//System.out.println("Nombre="+user.getNombre());
} catch (SQLException ex) {
Logger.getLogger(InterfazUsuario.class.getName()).log(Level.SEVERE, null, ex);
}
if(cadena.equals(null) || user.equals(null)){
JOptionPane.showMessageDialog(jPanel1, "No existe ningun usuario con el DNI introducido","Warning",2);
}
TextBuscaNom.setText(user.getNombre());
TextBuscaApelli.setText(user.getApellidos());
TextBuscaDNI.setText(user.getDNI());
TextEmail.setText(user.getCorreo());
TextFieldLogin.setText(user.getLogin());
PasswordFieldUsu.setText(user.getContrasena());
if(user.getEsGestor()==true){
RadioButtonGestor.setSelected(true);
RadioButtonEntrenador.setSelected(false);
}
else {
RadioButtonEntrenador.setSelected(true);
RadioButtonGestor.setSelected(false);
}
RadioButtonEntrenador.setVisible(true);
RadioButtonGestor.setVisible(true);
set_Editable(false);
jTextFieldBuscarUsu.setEditable(true);
}//GEN-LAST:event_jTextFieldBuscarUsuActionPerformed
private void TextApelliActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TextApelliActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_TextApelliActionPerformed
private void TextDNIActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TextDNIActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_TextDNIActionPerformed
private void RadioButtonEntrenaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RadioButtonEntrenaActionPerformed
// TODO add your handling code here:
if(RadioButtonEntrena.isSelected()){
jRadioButtonGestor.setSelected(false);
}
}//GEN-LAST:event_RadioButtonEntrenaActionPerformed
private void jButtonVolverAltaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonVolverAltaActionPerformed
// TODO add your handling code here:
jPanel3.setVisible(true);
jPanel5.setVisible(false);
jPanel1.setVisible(false);
}//GEN-LAST:event_jButtonVolverAltaActionPerformed
private void TextFieldLoginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TextFieldLoginActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_TextFieldLoginActionPerformed
private void TextFieldCorreoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TextFieldCorreoActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_TextFieldCorreoActionPerformed
private void jButtonModificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonModificarActionPerformed
// TODO add your handling code here:
jPanel3.setVisible(false);
jPanel5.setVisible(false);
PasswordConfir.setVisible(false);
jLabelNuevaContra.setVisible(true);
jTextFieldBuscarUsu.setVisible(false);
jLabel11.setVisible(false);
jLabel12.setText("Nueva Contraseña");
PasswordFieldUsu.setVisible(true);
jLabel12.setVisible(true);
PasswordConfir.setVisible(true);
RadioButtonGestor.setVisible(true);
RadioButtonEntrenador.setVisible(true);
set_Editable(true);
jButtonModificar.setVisible(false);
jButtonGuardar.setVisible(true);
jButtonBorrar.setVisible(true);
}//GEN-LAST:event_jButtonModificarActionPerformed
private void jButtonConfirmarAltaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonConfirmarAltaActionPerformed
// TODO add your handling code here:
jPanel1.setVisible(false);
jPanel3.setVisible(false);
String [] datos = new String [7];
datos = CargarDatosFormulario();
if(marcarErrores()){
JOptionPane.showMessageDialog(jPanel5,"Datos incompletos o erroneos !!!");
set_Editable(true);
} else{
ControladorUsuario.getInstancia().addUsuario(datos);
JOptionPane.showConfirmDialog(jPanel5,"Usuario registrado con exito","Message", 2);
limpiar();
}
}//GEN-LAST:event_jButtonConfirmarAltaActionPerformed
private void jRadioButtonGestorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButtonGestorActionPerformed
// TODO add your handling code here:
if(jRadioButtonGestor.isSelected()){
RadioButtonEntrena.setSelected(false);
}
}//GEN-LAST:event_jRadioButtonGestorActionPerformed
private void jButtonGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonGuardarActionPerformed
// TODO add your handling code here:
Usuario user = new Usuario();
try {
user = ControladorUsuario.getInstancia().getUsuario(TextBuscaDNI.getText().toString());
} catch (SQLException ex) {
Logger.getLogger(InterfazUsuario.class.getName()).log(Level.SEVERE, null, ex);
}
Boolean gestor;
String cadena1 = new String(PasswordFieldUsu.getPassword());
String cadena2 = new String(PasswordConfir.getPassword());
if(cadena1.equals(cadena2)){
if(RadioButtonGestor.isSelected()){
gestor = true;
}
else{
gestor = false;
}
user.setDNI(TextBuscaDNI.getText().toString());
user.setNombre(TextBuscaNom.getText().toString());
user.setApellidos(TextBuscaApelli.getText().toString());
user.setLogin(TextFieldLogin.getText().toString());
user.setContrasena(cadena1);
user.setCorreo(TextEmail.getText().toString());
user.setEsGestor(gestor);
try {
ControladorUsuario.getInstancia().updateUsuario(user);
} catch (SQLException ex) {
Logger.getLogger(InterfazUsuario.class.getName()).log(Level.SEVERE, null, ex);
}
JOptionPane.showMessageDialog(jPanel1, "Datos acualizados con exito", "Message",2);
}
else{
JOptionPane.showMessageDialog(jPanel1,"Las contraseñas no coinciden","Warning",1);
}
}//GEN-LAST:event_jButtonGuardarActionPerformed
private void RadioButtonGestorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RadioButtonGestorActionPerformed
// TODO add your handling code here:
if(RadioButtonGestor.isSelected()){
RadioButtonEntrenador.setSelected(false);
}
}//GEN-LAST:event_RadioButtonGestorActionPerformed
private void RadioButtonEntrenadorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RadioButtonEntrenadorActionPerformed
// TODO add your handling code here:
if(RadioButtonEntrenador.isSelected()){
RadioButtonGestor.setSelected(false);
}
}//GEN-LAST:event_RadioButtonEntrenadorActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel IconoFCB;
private javax.swing.JLabel IconoFCB1;
private javax.swing.JLabel IconoFCB2;
private javax.swing.JPasswordField PasswordConfir;
private javax.swing.JPasswordField PasswordFieldContra;
private javax.swing.JPasswordField PasswordFieldUsu;
private javax.swing.JRadioButton RadioButtonEntrena;
private javax.swing.JRadioButton RadioButtonEntrenador;
private javax.swing.JRadioButton RadioButtonGestor;
private javax.swing.JTextField TextAltaLogin;
private javax.swing.JTextField TextApelli;
private javax.swing.JTextField TextBuscaApelli;
private javax.swing.JTextField TextBuscaDNI;
private javax.swing.JTextField TextBuscaNom;
private javax.swing.JTextField TextDNI;
private javax.swing.JTextField TextEmail;
private javax.swing.JTextField TextFieldCorreo;
private javax.swing.JTextField TextFieldLogin;
private javax.swing.JTextField TextNombre;
private javax.swing.JLabel Titulo_JPanel;
private javax.swing.JLabel Titulo_JPanel1;
private javax.swing.JLabel Titulo_JPanel2;
private javax.swing.JButton jButtonAltaNuevoUsu;
private javax.swing.JButton jButtonBorrar;
private javax.swing.JButton jButtonConfirmarAlta;
private javax.swing.JButton jButtonConsultarUsu;
private javax.swing.JButton jButtonGuardar;
private javax.swing.JButton jButtonModificar;
private javax.swing.JButton jButtonVolver;
private javax.swing.JButton jButtonVolverAlta;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel16;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabelAltaContrasena;
private javax.swing.JLabel jLabelEmail;
private javax.swing.JLabel jLabelEmailAlta;
private javax.swing.JLabel jLabelLogin;
private javax.swing.JLabel jLabelNuevaContra;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel5;
private javax.swing.JRadioButton jRadioButtonGestor;
private javax.swing.JTextField jTextFieldBuscarUsu;
// End of variables declaration//GEN-END:variables
}