Professional Documents
Culture Documents
INGENIERÍA
“Año del Fortalecimiento de la Soberanía Nacional”
2022
Creación de un sistema de login y usuario
package proyecto02;
import java.awt.Image;
import java.awt.Toolkit;
import javax.swing.ImageIcon;
public login() {
initComponents();
this.setTitle("LOGIN");
this.setSize(500,500);
Image img=Toolkit.getDefaultToolkit().getImage(getClass().getResource("/img/
login.png"));
lblLogo.setIcon(new
ImageIcon(img.getScaledInstance(lblLogo.getWidth(),lblLogo.getHeight(),Image.SCALE_SM
OOTH)));
this.setIconImage(img);
this.setLocationRelativeTo(null);
cx=new Conexion("cecytem");
cx.conectar();
}
/**
* 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">
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
Usuario.setText("Usuario");
jLabel2.setText("Password");
jTextField1.setText("jTextField1");
jTextField2.setText("jTextField1");
btnIniciar.setText("Iniciar");
btnIniciar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnIniciarActionPerformed(evt);
}
});
Cancelar.setText("Cancelar");
Cancelar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CancelarActionPerformed(evt);
}
});
lblLogo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/login.png")));
// NOI18N
pack();
}// </editor-fold>
/**
* @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(login.class.getName()).log(java.util.logging.Level.SEVER
E, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVER
E, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVER
E, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVER
E, null, ex);
}
//</editor-fold>