Skip to content
This repository has been archived by the owner on May 9, 2020. It is now read-only.

Commit

Permalink
🔥 Added changes to login and panel_control
Browse files Browse the repository at this point in the history
  • Loading branch information
aitorru committed Oct 29, 2019
1 parent db06b78 commit 7dc616e
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 36 deletions.
14 changes: 14 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
{
"configurations": [
{
"type": "java",
"name": "CodeLens (Launch) - panel_control",
"request": "launch",
"mainClass": "com.AdministracionDrones.panel_control",
"projectName": "drones"
},
{
"type": "java",
"name": "CodeLens (Launch) - login",
"request": "launch",
"mainClass": "com.AdministracionDrones.login",
"projectName": "drones"
},
{
"type": "java",
"name": "CodeLens (Launch) - App",
Expand Down
2 changes: 1 addition & 1 deletion drones/src/main/java/com/AdministracionDrones/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
//login a = new login();
new login().setVisible(true);
// GUI Launcher
}
});
Expand Down
71 changes: 36 additions & 35 deletions drones/src/main/java/com/AdministracionDrones/login.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,22 @@ public class login extends javax.swing.JFrame {
private static final long serialVersionUID = 8155885392826282088L;

public login() {
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(login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
initComponents();
}

Expand Down Expand Up @@ -86,53 +102,38 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jButton1ActionPerformed
String usuario = jTextField1.getText();
String paswd = jPasswordField1.getPassword().toString();
char[] paswdCH = jPasswordField1.getPassword();
String paswd = "";
for (int i = 0; i < paswdCH.length; i++){
paswd = paswd + paswdCH[i];
}
userDB u = new userDB();
crypto c = new crypto();
ArrayList<HashMap<String, String>> listaUsuarios = u.leerBD();
for (int i = 0; i < listaUsuarios.size(); i++) {
HashMap<String, String> temp = listaUsuarios.get(i);
if (temp.get("user").equals(usuario)) {
if (temp.get("password").equals(c.StringToCrypto(paswd))) {
temp.get("idUsuario");
}
}
}

if (usuario.isEmpty() || paswd.isEmpty()) {
JOptionPane.showMessageDialog(null, "Algun campo esta vacio");

} else {
if (usuario.equals("admin") && paswd.equals("1234")) {
JOptionPane.showMessageDialog(null, "Bienvenido");
panel_control pc = new panel_control();
pc.setVisible(true);
this.dispose();

} else {
JOptionPane.showConfirmDialog(null, "Su usuario o contrase�a es incorrecto");
ArrayList<HashMap<String, String>> listaUsuarios = u.leerBD();
for (int i = 0; i < listaUsuarios.size(); i++) {
HashMap<String, String> temp = listaUsuarios.get(i);
if (temp.get("user").equals(usuario)) {
//Creado login con base de datos.
if (temp.get("password").equals(c.StringToCrypto(paswd))) {
// temp.get("idUsuario"); // Recogida de id de usuario para muestra especifia de drones
JOptionPane.showMessageDialog(null, "Bienvenido");
panel_control pc = new panel_control();
pc.setVisible(true);
this.dispose();
} else {
JOptionPane.showConfirmDialog(null, "Su usuario o contraseña es incorrecto");
}
}
}
}
}

public static void main(String args[]) {

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(login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
Expand Down

0 comments on commit 7dc616e

Please sign in to comment.