vista.ArchToxHome.java Source code

Java tutorial

Introduction

Here is the source code for vista.ArchToxHome.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package vista;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.Toolkit;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import org.apache.commons.codec.digest.DigestUtils;
import ws.usuario.Usuario;

/**
 *
 * @author Jonathan
 */
public class ArchToxHome extends javax.swing.JFrame {
    List<String> roles;
String nombre1, nombre2, apellido1, apellido2, correo, contrasea;
    int ID, role;
    char[] pass;

    private final String PATTERN_EMAIL = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@"
            + "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";

    /**
     * Creates new form ArchToxHome
     */
    public ArchToxHome() {
        initComponents();
        this.setLocationRelativeTo(null);
        this.setResizable(false);
        ImageIcon img = new ImageIcon(
                "C:\\Users\\Jonathan\\Documents\\NetBeansProjects\\ArchTox\\src\\imagenes\\archtox.png");
        Icon icono = new ImageIcon(
                img.getImage().getScaledInstance(LabelLogo.getWidth(), LabelLogo.getHeight(), Image.SCALE_SMOOTH));
        LabelLogo.setIcon(icono);
        this.repaint();
        //        Dimension tamao = Toolkit.getDefaultToolkit().getScreenSize();
        //        this.setSize(tamao);
    }

    @Override
    public Image getIconImage() {
        Image retValue = Toolkit.getDefaultToolkit()
                .getImage(ClassLoader.getSystemResource("imagenes/archtox.png"));
        return retValue;
    }

    /**
     * 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() {

        PanelHeader = new javax.swing.JPanel();
        ButtonAddUser = new javax.swing.JLabel();
        ButtonAddItem = new javax.swing.JLabel();
        ButtonAddGroup = new javax.swing.JLabel();
        ButtonListItems = new javax.swing.JLabel();
        LabelInfo = new javax.swing.JLabel();
        jSeparator9 = new javax.swing.JSeparator();
        jLabel15 = new javax.swing.JLabel();
        LabelLogo = new javax.swing.JLabel();
        LabelNombre = new javax.swing.JLabel();
        PanelContent = new javax.swing.JPanel();
        PanelGuas = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        PanelFarmaco = new javax.swing.JPanel();
        PanelGrupo = new javax.swing.JPanel();
        PanelUsuario = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        CampoNombre1 = new javax.swing.JTextField();
        jSeparator1 = new javax.swing.JSeparator();
        CampoNombre2 = new javax.swing.JTextField();
        jSeparator2 = new javax.swing.JSeparator();
        CampoApellido1 = new javax.swing.JTextField();
        jSeparator3 = new javax.swing.JSeparator();
        CampoApellido2 = new javax.swing.JTextField();
        jSeparator5 = new javax.swing.JSeparator();
        jPanel2 = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        CampoCorreo = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        ComboRoles = new javax.swing.JComboBox<>();
        jSeparator7 = new javax.swing.JSeparator();
        jSeparator8 = new javax.swing.JSeparator();
        jPanel3 = new javax.swing.JPanel();
        jLabel10 = new javax.swing.JLabel();
        CampoID = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        CampoPass = new javax.swing.JPasswordField();
        jSeparator4 = new javax.swing.JSeparator();
        jSeparator6 = new javax.swing.JSeparator();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        PanelButtonEntrar = new javax.swing.JPanel();
        jLabel14 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Home - ArchTox: Gua de Manejo para Pacientes Intoxicados");
        setBackground(new java.awt.Color(255, 255, 255));
        setIconImage(getIconImage());

        PanelHeader.setBackground(new java.awt.Color(255, 51, 51));

        ButtonAddUser.setBackground(new java.awt.Color(255, 51, 51));
        ButtonAddUser.setFont(new java.awt.Font("Century Gothic", 1, 14)); // NOI18N
        ButtonAddUser.setForeground(new java.awt.Color(255, 255, 255));
        ButtonAddUser.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        ButtonAddUser.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/AddUser.png"))); // NOI18N
        ButtonAddUser.setText("Usuario");
        ButtonAddUser.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        ButtonAddUser.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        ButtonAddUser.setOpaque(true);
        ButtonAddUser.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                ButtonAddUserMouseClicked(evt);
            }
        });

        ButtonAddItem.setBackground(new java.awt.Color(255, 51, 51));
        ButtonAddItem.setFont(new java.awt.Font("Century Gothic", 1, 14)); // NOI18N
        ButtonAddItem.setForeground(new java.awt.Color(255, 255, 255));
        ButtonAddItem.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        ButtonAddItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/AddItem.png"))); // NOI18N
        ButtonAddItem.setText("Frmaco");
        ButtonAddItem.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        ButtonAddItem.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        ButtonAddItem.setOpaque(true);
        ButtonAddItem.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                ButtonAddItemMouseClicked(evt);
            }
        });

        ButtonAddGroup.setBackground(new java.awt.Color(255, 51, 51));
        ButtonAddGroup.setFont(new java.awt.Font("Century Gothic", 1, 14)); // NOI18N
        ButtonAddGroup.setForeground(new java.awt.Color(255, 255, 255));
        ButtonAddGroup.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        ButtonAddGroup.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/AddGroup.png"))); // NOI18N
        ButtonAddGroup.setText("G. Farmac.");
        ButtonAddGroup.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        ButtonAddGroup.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        ButtonAddGroup.setOpaque(true);
        ButtonAddGroup.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                ButtonAddGroupMouseClicked(evt);
            }
        });

        ButtonListItems.setBackground(new java.awt.Color(168, 28, 28));
        ButtonListItems.setFont(new java.awt.Font("Century Gothic", 1, 14)); // NOI18N
        ButtonListItems.setForeground(new java.awt.Color(255, 255, 255));
        ButtonListItems.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        ButtonListItems.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/ListItems.png"))); // NOI18N
        ButtonListItems.setText("Guas");
        ButtonListItems.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        ButtonListItems.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        ButtonListItems.setOpaque(true);
        ButtonListItems.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                ButtonListItemsMouseClicked(evt);
            }
        });

        LabelInfo.setFont(new java.awt.Font("Castellar", 0, 40)); // NOI18N
        LabelInfo.setText("ArchTox");

        jLabel15.setFont(new java.awt.Font("Century Gothic", 1, 14)); // NOI18N
        jLabel15.setForeground(new java.awt.Color(255, 255, 255));
        jLabel15.setText("Bienvenido(a) ");

        LabelLogo.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);

        LabelNombre.setFont(new java.awt.Font("Century Gothic", 1, 14)); // NOI18N
        LabelNombre.setText("Usuario");

        javax.swing.GroupLayout PanelHeaderLayout = new javax.swing.GroupLayout(PanelHeader);
        PanelHeader.setLayout(PanelHeaderLayout);
        PanelHeaderLayout.setHorizontalGroup(PanelHeaderLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(PanelHeaderLayout.createSequentialGroup().addGap(69, 69, 69).addGroup(PanelHeaderLayout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addGroup(PanelHeaderLayout.createSequentialGroup()
                                .addComponent(ButtonListItems, javax.swing.GroupLayout.PREFERRED_SIZE, 160,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(ButtonAddItem, javax.swing.GroupLayout.PREFERRED_SIZE, 160,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(PanelHeaderLayout.createSequentialGroup()
                                .addComponent(LabelLogo, javax.swing.GroupLayout.PREFERRED_SIZE, 66,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addGroup(PanelHeaderLayout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                        .addComponent(jSeparator9, javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(LabelInfo, javax.swing.GroupLayout.Alignment.LEADING))
                                .addGap(9, 9, 9)))
                        .addComponent(ButtonAddGroup, javax.swing.GroupLayout.PREFERRED_SIZE, 160,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(PanelHeaderLayout
                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(jLabel15)
                                .addComponent(ButtonAddUser, javax.swing.GroupLayout.DEFAULT_SIZE, 160,
                                        Short.MAX_VALUE)
                                .addComponent(LabelNombre, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
        PanelHeaderLayout.setVerticalGroup(PanelHeaderLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PanelHeaderLayout.createSequentialGroup()
                        .addGap(36, 36, 36)
                        .addGroup(PanelHeaderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(PanelHeaderLayout.createSequentialGroup().addComponent(jLabel15)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(LabelNombre))
                                .addComponent(LabelLogo, javax.swing.GroupLayout.Alignment.TRAILING,
                                        javax.swing.GroupLayout.PREFERRED_SIZE, 65,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGroup(PanelHeaderLayout.createSequentialGroup().addComponent(LabelInfo)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jSeparator9, javax.swing.GroupLayout.PREFERRED_SIZE, 10,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 57, Short.MAX_VALUE)
                        .addGroup(PanelHeaderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(ButtonAddUser).addComponent(ButtonListItems)
                                .addComponent(ButtonAddItem).addComponent(ButtonAddGroup))));

        PanelContent.setLayout(new java.awt.CardLayout());

        PanelGuas.setLayout(new javax.swing.BoxLayout(PanelGuas, javax.swing.BoxLayout.LINE_AXIS));

        jTable1.setModel(
                new javax.swing.table.DefaultTableModel(
                        new Object[][] { { null, null, null, null }, { null, null, null, null },
                                { null, null, null, null }, { null, null, null, null } },
                        new String[] { "Title 1", "Title 2", "Title 3", "Title 4" }));
        jScrollPane1.setViewportView(jTable1);

        PanelGuas.add(jScrollPane1);

        PanelContent.add(PanelGuas, "card2");

        javax.swing.GroupLayout PanelFarmacoLayout = new javax.swing.GroupLayout(PanelFarmaco);
        PanelFarmaco.setLayout(PanelFarmacoLayout);
        PanelFarmacoLayout.setHorizontalGroup(PanelFarmacoLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 810, Short.MAX_VALUE));
        PanelFarmacoLayout.setVerticalGroup(PanelFarmacoLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 309, Short.MAX_VALUE));

        PanelContent.add(PanelFarmaco, "card3");

        javax.swing.GroupLayout PanelGrupoLayout = new javax.swing.GroupLayout(PanelGrupo);
        PanelGrupo.setLayout(PanelGrupoLayout);
        PanelGrupoLayout.setHorizontalGroup(PanelGrupoLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 810, Short.MAX_VALUE));
        PanelGrupoLayout.setVerticalGroup(PanelGrupoLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 309, Short.MAX_VALUE));

        PanelContent.add(PanelGrupo, "card3");

        PanelUsuario.setBackground(new java.awt.Color(36, 47, 65));

        jPanel1.setBackground(new java.awt.Color(106, 116, 145));

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/contact.png"))); // NOI18N

        jLabel2.setFont(new java.awt.Font("Century Gothic", 1, 14)); // NOI18N
        jLabel2.setForeground(new java.awt.Color(255, 255, 255));
        jLabel2.setText("Primer Nombre");

        jLabel3.setFont(new java.awt.Font("Century Gothic", 1, 14)); // NOI18N
        jLabel3.setForeground(new java.awt.Color(255, 255, 255));
        jLabel3.setText("Segundo Nombre");

        jLabel4.setFont(new java.awt.Font("Century Gothic", 1, 14)); // NOI18N
        jLabel4.setForeground(new java.awt.Color(255, 255, 255));
        jLabel4.setText("Primer Apellido");

        jLabel5.setFont(new java.awt.Font("Century Gothic", 1, 14)); // NOI18N
        jLabel5.setForeground(new java.awt.Color(255, 255, 255));
        jLabel5.setText("Segundo Apellido");

        CampoNombre1.setBackground(new java.awt.Color(36, 47, 65));
        CampoNombre1.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        CampoNombre1.setForeground(new java.awt.Color(255, 255, 255));
        CampoNombre1.setBorder(null);

        CampoNombre2.setBackground(new java.awt.Color(36, 47, 65));
        CampoNombre2.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        CampoNombre2.setForeground(new java.awt.Color(255, 255, 255));
        CampoNombre2.setBorder(null);

        CampoApellido1.setBackground(new java.awt.Color(36, 47, 65));
        CampoApellido1.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        CampoApellido1.setForeground(new java.awt.Color(255, 255, 255));
        CampoApellido1.setBorder(null);

        CampoApellido2.setBackground(new java.awt.Color(36, 47, 65));
        CampoApellido2.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        CampoApellido2.setForeground(new java.awt.Color(255, 255, 255));
        CampoApellido2.setBorder(null);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(jPanel1Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup().addGroup(jPanel1Layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel1Layout.createSequentialGroup().addGap(97, 97, 97).addComponent(jLabel1)
                                .addGap(0, 0, Short.MAX_VALUE))
                        .addGroup(jPanel1Layout.createSequentialGroup().addGap(10, 10, 10).addGroup(jPanel1Layout
                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel1Layout.createSequentialGroup().addComponent(jLabel5)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(CampoApellido2))
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                        jPanel1Layout.createSequentialGroup()
                                                .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 122,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(CampoApellido1,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 95,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 122,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(CampoNombre2))))
                        .addGroup(jPanel1Layout.createSequentialGroup().addGap(10, 10, 10)
                                .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 122,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(CampoNombre1)))
                        .addGap(10, 10, 10))
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jSeparator2, javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jSeparator3, javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jSeparator5, javax.swing.GroupLayout.Alignment.TRAILING))
                        .addContainerGap()));
        jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup().addGap(11, 11, 11)
                        .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 76,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(6, 6, 6)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 20,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(CampoNombre1, javax.swing.GroupLayout.PREFERRED_SIZE, 19,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(5, 5, 5)
                        .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(11, 11, 11)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel3).addComponent(CampoNombre2,
                                        javax.swing.GroupLayout.PREFERRED_SIZE, 19,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(11, 11, 11)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 20,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(CampoApellido1, javax.swing.GroupLayout.PREFERRED_SIZE, 19,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(5, 5, 5)
                        .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 10,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(11, 11, 11)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 20,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(CampoApellido2, javax.swing.GroupLayout.PREFERRED_SIZE, 19,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(5, 5, 5)
                        .addComponent(jSeparator5, javax.swing.GroupLayout.PREFERRED_SIZE, 10,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

        jPanel2.setBackground(new java.awt.Color(106, 116, 145));

        jLabel6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/email.png"))); // NOI18N

        CampoCorreo.setBackground(new java.awt.Color(36, 47, 65));
        CampoCorreo.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        CampoCorreo.setForeground(new java.awt.Color(255, 255, 255));
        CampoCorreo.setText("Ingresa el email");
        CampoCorreo.setBorder(null);
        CampoCorreo.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                CampoCorreoMouseClicked(evt);
            }
        });
        CampoCorreo.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                CampoCorreoKeyTyped(evt);
            }
        });

        jLabel7.setFont(new java.awt.Font("Century Gothic", 1, 14)); // NOI18N
        jLabel7.setForeground(new java.awt.Color(255, 255, 255));
        jLabel7.setText("CORREO");

        jLabel8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/rol.png"))); // NOI18N

        jLabel9.setFont(new java.awt.Font("Century Gothic", 1, 14)); // NOI18N
        jLabel9.setForeground(new java.awt.Color(255, 255, 255));
        jLabel9.setText("ROLE");

        ComboRoles.setFont(new java.awt.Font("Century Gothic", 0, 10)); // NOI18N

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(jPanel2Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel2Layout.createSequentialGroup().addComponent(jLabel6)
                                        .addGap(6, 6, 6)
                                        .addGroup(jPanel2Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addGroup(jPanel2Layout.createSequentialGroup()
                                                        .addComponent(jLabel7).addGap(0, 0, Short.MAX_VALUE))
                                                .addComponent(CampoCorreo).addComponent(jSeparator8)))
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout
                                        .createSequentialGroup().addComponent(jLabel8)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(jPanel2Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addGroup(jPanel2Layout.createSequentialGroup()
                                                        .addComponent(jLabel9).addGap(128, 128, 128))
                                                .addComponent(jSeparator7).addComponent(ComboRoles,
                                                        javax.swing.GroupLayout.Alignment.TRAILING, 0,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                        .addContainerGap()));
        jPanel2Layout
                .setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap(42, Short.MAX_VALUE)
                                .addGroup(jPanel2Layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addComponent(jLabel8)
                                        .addGroup(jPanel2Layout.createSequentialGroup().addComponent(jLabel9)
                                                .addGap(11, 11, 11)
                                                .addComponent(ComboRoles, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(jSeparator7, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        10, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGap(18, 18, 18)
                                .addGroup(jPanel2Layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(jLabel6)
                                        .addGroup(jPanel2Layout.createSequentialGroup().addComponent(jLabel7)
                                                .addPreferredGap(
                                                        javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                .addComponent(CampoCorreo, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        20, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(jSeparator8, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        10, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGap(57, 57, 57)));

        jPanel3.setBackground(new java.awt.Color(106, 116, 145));

        jLabel10.setFont(new java.awt.Font("Century Gothic", 1, 14)); // NOI18N
        jLabel10.setForeground(new java.awt.Color(255, 255, 255));
        jLabel10.setText("USER ID");

        CampoID.setBackground(new java.awt.Color(36, 47, 65));
        CampoID.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        CampoID.setForeground(new java.awt.Color(255, 255, 255));
        CampoID.setText("Ingresa el ID del usuario");
        CampoID.setBorder(null);
        CampoID.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                CampoIDMouseClicked(evt);
            }
        });
        CampoID.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                CampoIDKeyTyped(evt);
            }
        });

        jLabel11.setFont(new java.awt.Font("Century Gothic", 1, 14)); // NOI18N
        jLabel11.setForeground(new java.awt.Color(255, 255, 255));
        jLabel11.setText("CONTRASEA");

        CampoPass.setBackground(new java.awt.Color(36, 47, 65));
        CampoPass.setForeground(new java.awt.Color(255, 255, 255));
        CampoPass.setText("jPasswordField1");
        CampoPass.setBorder(null);
        CampoPass.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                CampoPassMouseClicked(evt);
            }
        });

        jLabel12.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/ID.png"))); // NOI18N

        jLabel13.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/pass.png"))); // NOI18N

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(jPanel3Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel12).addComponent(jLabel13))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 10, Short.MAX_VALUE)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel10).addComponent(jLabel11)
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                        jPanel3Layout.createSequentialGroup().addGroup(jPanel3Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                                        false)
                                                .addComponent(jSeparator6,
                                                        javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(CampoPass, javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jSeparator4,
                                                        javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(CampoID, javax.swing.GroupLayout.DEFAULT_SIZE, 170,
                                                        Short.MAX_VALUE))
                                                .addContainerGap()))));
        jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel3Layout.createSequentialGroup().addGap(41, 41, 41).addGroup(jPanel3Layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(jPanel3Layout.createSequentialGroup().addComponent(jLabel10).addGap(11, 11, 11)
                                .addComponent(CampoID, javax.swing.GroupLayout.PREFERRED_SIZE, 20,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(0, 0, 0).addComponent(jSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        10, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addComponent(jLabel12))
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel3Layout.createSequentialGroup().addGap(20, 20, 20)
                                        .addComponent(jLabel11).addGap(11, 11, 11)
                                        .addComponent(CampoPass, javax.swing.GroupLayout.PREFERRED_SIZE, 20,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(0, 0, 0)
                                        .addComponent(jSeparator6, javax.swing.GroupLayout.PREFERRED_SIZE, 10,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(jPanel3Layout.createSequentialGroup()
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jLabel13)))
                        .addContainerGap(64, Short.MAX_VALUE)));

        PanelButtonEntrar.setBackground(new java.awt.Color(255, 102, 102));
        PanelButtonEntrar.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        PanelButtonEntrar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                PanelButtonEntrarMouseClicked(evt);
            }
        });

        jLabel14.setFont(new java.awt.Font("Century Gothic", 1, 14)); // NOI18N
        jLabel14.setText("REGISTRAR USUARIO");

        javax.swing.GroupLayout PanelButtonEntrarLayout = new javax.swing.GroupLayout(PanelButtonEntrar);
        PanelButtonEntrar.setLayout(PanelButtonEntrarLayout);
        PanelButtonEntrarLayout.setHorizontalGroup(
                PanelButtonEntrarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(PanelButtonEntrarLayout.createSequentialGroup().addGap(190, 190, 190)
                                .addComponent(jLabel14)
                                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
        PanelButtonEntrarLayout.setVerticalGroup(PanelButtonEntrarLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jLabel14,
                        javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE));

        javax.swing.GroupLayout PanelUsuarioLayout = new javax.swing.GroupLayout(PanelUsuario);
        PanelUsuario.setLayout(PanelUsuarioLayout);
        PanelUsuarioLayout.setHorizontalGroup(PanelUsuarioLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(PanelUsuarioLayout.createSequentialGroup().addContainerGap()
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addGroup(PanelUsuarioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(PanelUsuarioLayout.createSequentialGroup()
                                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(18, 18, 18).addComponent(jPanel3,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addComponent(PanelButtonEntrar, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addContainerGap()));
        PanelUsuarioLayout.setVerticalGroup(PanelUsuarioLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(PanelUsuarioLayout.createSequentialGroup().addContainerGap()
                        .addGroup(PanelUsuarioLayout
                                .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        Short.MAX_VALUE)
                                .addGroup(PanelUsuarioLayout.createSequentialGroup()
                                        .addGroup(PanelUsuarioLayout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                                .addComponent(jPanel2, 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))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(PanelButtonEntrar, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

        PanelContent.add(PanelUsuario, "card3");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(PanelHeader, javax.swing.GroupLayout.DEFAULT_SIZE,
                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(PanelContent, javax.swing.GroupLayout.DEFAULT_SIZE,
                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                        .addComponent(PanelHeader, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(PanelContent, javax.swing.GroupLayout.DEFAULT_SIZE, 309, Short.MAX_VALUE)));

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void ButtonListItemsMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ButtonListItemsMouseClicked
        setButtonColor(ButtonListItems);
        resetButtonColor(ButtonAddItem);
        resetButtonColor(ButtonAddGroup);
        resetButtonColor(ButtonAddUser);

        PanelGuas.setVisible(true);
        PanelFarmaco.setVisible(false);
        PanelGrupo.setVisible(false);
        PanelUsuario.setVisible(false);
    }//GEN-LAST:event_ButtonListItemsMouseClicked

    private void ButtonAddItemMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ButtonAddItemMouseClicked
        resetButtonColor(ButtonListItems);
        setButtonColor(ButtonAddItem);
        resetButtonColor(ButtonAddGroup);
        resetButtonColor(ButtonAddUser);

        PanelGuas.setVisible(false);
        PanelFarmaco.setVisible(true);
        PanelGrupo.setVisible(false);
        PanelUsuario.setVisible(false);
    }//GEN-LAST:event_ButtonAddItemMouseClicked

    private void ButtonAddGroupMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ButtonAddGroupMouseClicked
        resetButtonColor(ButtonListItems);
        resetButtonColor(ButtonAddItem);
        setButtonColor(ButtonAddGroup);
        resetButtonColor(ButtonAddUser);

        PanelGuas.setVisible(false);
        PanelFarmaco.setVisible(false);
        PanelGrupo.setVisible(true);
        PanelUsuario.setVisible(false);
    }//GEN-LAST:event_ButtonAddGroupMouseClicked

    private void ButtonAddUserMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ButtonAddUserMouseClicked
        resetButtonColor(ButtonListItems);
        resetButtonColor(ButtonAddItem);
        resetButtonColor(ButtonAddGroup);
        setButtonColor(ButtonAddUser);

        PanelGuas.setVisible(false);
        PanelFarmaco.setVisible(false);
        PanelGrupo.setVisible(false);
        PanelUsuario.setVisible(true);

        roles = listarRoles();

        for (int i = 0; i < roles.size(); i++) {
            ComboRoles.addItem(roles.get(i));
        }

    }//GEN-LAST:event_ButtonAddUserMouseClicked

    private void CampoCorreoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_CampoCorreoMouseClicked
        //        CampoID.setText("");
    }//GEN-LAST:event_CampoCorreoMouseClicked

    private void CampoCorreoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_CampoCorreoKeyTyped

    }//GEN-LAST:event_CampoCorreoKeyTyped

    private void CampoIDMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_CampoIDMouseClicked
        //        CampoID.setText("");
    }//GEN-LAST:event_CampoIDMouseClicked

    private void CampoIDKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_CampoIDKeyTyped
        Consume(evt);
        if (CampoID.getText().length() == 10) {
            evt.consume();
        }
    }//GEN-LAST:event_CampoIDKeyTyped

    private void CampoPassMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_CampoPassMouseClicked
        //        CampoPass.setText("");
    }//GEN-LAST:event_CampoPassMouseClicked

private void PanelButtonEntrarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_PanelButtonEntrarMouseClicked
    nombre1 = CampoNombre1.getText(); nombre2 = CampoNombre2.getText(); apellido1 = CampoApellido1.getText();
    apellido2 = CampoApellido2.getText(); correo = CampoCorreo.getText();
    pass = CampoPass.getPassword(); 
    contrasea = new String(pass);
    if(nombre1.isEmpty() || apellido1.isEmpty() || apellido2.isEmpty() || correo.isEmpty()
            || contrasea.isEmpty() || CampoID.getText().isEmpty()){
        JOptionPane.showMessageDialog(this, "Por favor rellene todos los campos.", "ERROR", JOptionPane.ERROR_MESSAGE);
    }else{
        try {
            ID = Integer.parseInt(CampoID.getText());
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Igrese el User ID", "ERROR", JOptionPane.ERROR_MESSAGE);
            return;
        }
            
        if(nombre2.isEmpty()) nombre2 = "null";
            
        if(validateEmail(correo)){
            String mensaje = agregarUsuario(ComboRoles.getSelectedIndex()+1, ID, 
            nombre1+"-"+nombre2, apellido1+"-"+apellido2, correo, DigestUtils.md5Hex(contrasea));
            JOptionPane.showMessageDialog(this, mensaje, "Mensaje", JOptionPane.INFORMATION_MESSAGE);
            if(mensaje.equals("Usuario agregado con xito.")){
                CampoNombre1.setText(""); CampoNombre2.setText(""); CampoApellido1.setText("");
                CampoApellido2.setText(""); CampoCorreo.setText("Ingresa el email");
                ComboRoles.setSelectedItem(0);
                CampoID.setText("Ingresa el ID del usuario");
                CampoPass.setText("jPasswordField1");
            }
        }else{
            JOptionPane.showMessageDialog(this, "Ingrese un correo vlido.", "ERROR", JOptionPane.ERROR_MESSAGE);
        }
    }
}//GEN-LAST:event_PanelButtonEntrarMouseClicked

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(ArchToxHome.class.getName()).log(java.util.logging.Level.SEVERE,
                    null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(ArchToxHome.class.getName()).log(java.util.logging.Level.SEVERE,
                    null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(ArchToxHome.class.getName()).log(java.util.logging.Level.SEVERE,
                    null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(ArchToxHome.class.getName()).log(java.util.logging.Level.SEVERE,
                    null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new ArchToxHome().setVisible(true);
            }
        });
    }

    public void setButtonColor(javax.swing.JLabel label) {
        label.setBackground(new Color(168, 28, 28));
    }

    public void resetButtonColor(javax.swing.JLabel label) {
        label.setBackground(new Color(255, 51, 51));
    }

    private void Consume(java.awt.event.KeyEvent evt) {
        char c = evt.getKeyChar();
        if (c < '0' || c > '9') {
            evt.consume();
        }
    }

    public static void setUser(int user_id) {
        String fullname = obtenerNombreUsuario(user_id), name[] = fullname.split("-");
        LabelNombre.setText(name[0] + " " + name[2]);
    }

    public boolean validateEmail(String email) {

        // Compiles the given regular expression into a pattern.
        Pattern pattern = Pattern.compile(PATTERN_EMAIL);

        // Match the given input against this pattern
        Matcher matcher = pattern.matcher(email);
        return matcher.matches();

    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel ButtonAddGroup;
    private javax.swing.JLabel ButtonAddItem;
    private javax.swing.JLabel ButtonAddUser;
    private javax.swing.JLabel ButtonListItems;
    private javax.swing.JTextField CampoApellido1;
    private javax.swing.JTextField CampoApellido2;
    private javax.swing.JTextField CampoCorreo;
    private javax.swing.JTextField CampoID;
    private javax.swing.JTextField CampoNombre1;
    private javax.swing.JTextField CampoNombre2;
    private javax.swing.JPasswordField CampoPass;
    private javax.swing.JComboBox<String> ComboRoles;
    private javax.swing.JLabel LabelInfo;
    private javax.swing.JLabel LabelLogo;
    private static javax.swing.JLabel LabelNombre;
    private javax.swing.JPanel PanelButtonEntrar;
    private javax.swing.JPanel PanelContent;
    private javax.swing.JPanel PanelFarmaco;
    private javax.swing.JPanel PanelGrupo;
    private javax.swing.JPanel PanelGuas;
    private javax.swing.JPanel PanelHeader;
    private javax.swing.JPanel PanelUsuario;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JSeparator jSeparator4;
    private javax.swing.JSeparator jSeparator5;
    private javax.swing.JSeparator jSeparator6;
    private javax.swing.JSeparator jSeparator7;
    private javax.swing.JSeparator jSeparator8;
    private javax.swing.JSeparator jSeparator9;
    private javax.swing.JTable jTable1;
    // End of variables declaration//GEN-END:variables

    private static java.util.List<java.lang.String> listarRoles() {
        ws.rol.WSRole_Service service = new ws.rol.WSRole_Service();
        ws.rol.WSRole port = service.getWSRolePort();
        return port.listarRoles();
    }

    private static String agregarUsuario(int idRol, int idUser, java.lang.String nombre, java.lang.String apellidos,
            java.lang.String correo, java.lang.String keyPass) {
        ws.usuario.WSUsuario_Service service = new ws.usuario.WSUsuario_Service();
        ws.usuario.WSUsuario port = service.getWSUsuarioPort();
        return port.agregarUsuario(idRol, idUser, nombre, apellidos, correo, keyPass);
    }

    private static String obtenerNombreUsuario(int idUser) {
        ws.usuario.WSUsuario_Service service = new ws.usuario.WSUsuario_Service();
        ws.usuario.WSUsuario port = service.getWSUsuarioPort();
        return port.obtenerNombreUsuario(idUser);
    }
}