Advertisement
Guest User

MITHON CHANDRA

a guest
Feb 21st, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 11.40 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package Logins;
  7.  
  8. import javax.swing.JOptionPane;
  9. import java.awt.Toolkit;
  10. import java.awt.event.WindowEvent;
  11. import Logins.Login_s;
  12.  
  13. /**
  14.  *
  15.  * @author ASUS-PC
  16.  */
  17. public class Login extends javax.swing.JFrame {
  18.  
  19.     /**
  20.      * Creates new form Login
  21.      */
  22.     public Login() {
  23.         initComponents();
  24.     }
  25.  
  26.     /**
  27.      * This method is called from within the constructor to initialize the form.
  28.      * WARNING: Do NOT modify this code. The content of this method is always
  29.      * regenerated by the Form Editor.
  30.      */
  31.     @SuppressWarnings("unchecked")
  32.     // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
  33.     private void initComponents() {
  34.  
  35.         jPanel1 = new javax.swing.JPanel();
  36.         jLabel2 = new javax.swing.JLabel();
  37.         jLabel3 = new javax.swing.JLabel();
  38.         jtxtUserName = new javax.swing.JTextField();
  39.         jPassword = new javax.swing.JPasswordField();
  40.         jbtnLogin = new javax.swing.JButton();
  41.         jbtnReset = new javax.swing.JButton();
  42.         jbtnExit = new javax.swing.JButton();
  43.         jLabel1 = new javax.swing.JLabel();
  44.  
  45.         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  46.  
  47.         jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0), 30));
  48.  
  49.         jLabel2.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
  50.         jLabel2.setText("Username");
  51.  
  52.         jLabel3.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
  53.         jLabel3.setText("Password");
  54.  
  55.         jtxtUserName.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
  56.         jtxtUserName.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0), 4));
  57.  
  58.         jPassword.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
  59.         jPassword.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0), 4));
  60.  
  61.         jbtnLogin.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
  62.         jbtnLogin.setText("Login");
  63.         jbtnLogin.addActionListener(new java.awt.event.ActionListener() {
  64.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  65.                 jbtnLoginActionPerformed(evt);
  66.             }
  67.         });
  68.  
  69.         jbtnReset.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
  70.         jbtnReset.setText("Reset");
  71.         jbtnReset.addActionListener(new java.awt.event.ActionListener() {
  72.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  73.                 jbtnResetActionPerformed(evt);
  74.             }
  75.         });
  76.  
  77.         jbtnExit.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
  78.         jbtnExit.setText("Exit");
  79.         jbtnExit.addActionListener(new java.awt.event.ActionListener() {
  80.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  81.                 jbtnExitActionPerformed(evt);
  82.             }
  83.         });
  84.  
  85.         javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
  86.         jPanel1.setLayout(jPanel1Layout);
  87.         jPanel1Layout.setHorizontalGroup(
  88.             jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  89.             .addGroup(jPanel1Layout.createSequentialGroup()
  90.                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  91.                     .addGroup(jPanel1Layout.createSequentialGroup()
  92.                         .addContainerGap()
  93.                         .addComponent(jbtnLogin)
  94.                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  95.                         .addComponent(jbtnReset))
  96.                     .addGroup(jPanel1Layout.createSequentialGroup()
  97.                         .addGap(41, 41, 41)
  98.                         .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  99.                             .addComponent(jLabel3)
  100.                             .addComponent(jLabel2))))
  101.                 .addGap(7, 7, 7)
  102.                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  103.                     .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  104.                         .addGroup(jPanel1Layout.createSequentialGroup()
  105.                             .addComponent(jbtnExit, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
  106.                             .addGap(213, 213, 213))
  107.                         .addComponent(jtxtUserName, javax.swing.GroupLayout.PREFERRED_SIZE, 360, javax.swing.GroupLayout.PREFERRED_SIZE))
  108.                     .addComponent(jPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 360, javax.swing.GroupLayout.PREFERRED_SIZE))
  109.                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  110.         );
  111.         jPanel1Layout.setVerticalGroup(
  112.             jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  113.             .addGroup(jPanel1Layout.createSequentialGroup()
  114.                 .addGap(20, 20, 20)
  115.                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  116.                     .addComponent(jtxtUserName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  117.                     .addComponent(jLabel2))
  118.                 .addGap(31, 31, 31)
  119.                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  120.                     .addComponent(jPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  121.                     .addComponent(jLabel3))
  122.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 101, Short.MAX_VALUE)
  123.                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  124.                     .addComponent(jbtnLogin)
  125.                     .addComponent(jbtnReset)
  126.                     .addComponent(jbtnExit))
  127.                 .addGap(28, 28, 28))
  128.         );
  129.  
  130.         jLabel1.setFont(new java.awt.Font("Tahoma", 1, 48)); // NOI18N
  131.         jLabel1.setText("     Login System");
  132.         jLabel1.setVerticalAlignment(javax.swing.SwingConstants.TOP);
  133.  
  134.         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  135.         getContentPane().setLayout(layout);
  136.         layout.setHorizontalGroup(
  137.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  138.             .addGroup(layout.createSequentialGroup()
  139.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  140.                     .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  141.                     .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 485, javax.swing.GroupLayout.PREFERRED_SIZE))
  142.                 .addGap(0, 29, Short.MAX_VALUE))
  143.         );
  144.         layout.setVerticalGroup(
  145.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  146.             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  147.                 .addGap(31, 31, 31)
  148.                 .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  149.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  150.                 .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  151.                 .addGap(20, 20, 20))
  152.         );
  153.  
  154.         pack();
  155.     }// </editor-fold>                        
  156.  
  157.     private void jbtnExitActionPerformed(java.awt.event.ActionEvent evt) {                                        
  158.       System.exit(0);
  159.     }                                        
  160.  
  161.     private void jbtnResetActionPerformed(java.awt.event.ActionEvent evt) {                                          
  162.       jtxtUserName.setText(null);
  163.       jPassword.setText(null);
  164.     }                                        
  165.  
  166.     private void jbtnLoginActionPerformed(java.awt.event.ActionEvent evt) {                                          
  167.      String password = jPassword.getText();
  168.      String username = jtxtUserName.getText();
  169.      if (password.contains("mit")&&(username.contains("mithon")))
  170.      {
  171.          jtxtUserName.setText(null);
  172.          jPassword.setText(null);
  173.          systemExit();
  174.          
  175.          Login_s Info = new Login_s();
  176.          Info.setVisible(true);
  177.      }
  178.       else
  179.             {
  180.                 JOptionPane.showMessageDialog(null,"Invalid Login Details", "Login Error", JOptionPane.ERROR_MESSAGE);
  181.               jPassword.setText(null);
  182.               jtxtUserName.setText(null);
  183.             }
  184.     }                                        
  185.  
  186.     /**
  187.      * @param args the command line arguments
  188.      */
  189.     public static void main(String args[]) {
  190.         /* Set the Nimbus look and feel */
  191.         //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  192.         /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  193.          * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  194.          */
  195.         try {
  196.             for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  197.                 if ("Nimbus".equals(info.getName())) {
  198.                     javax.swing.UIManager.setLookAndFeel(info.getClassName());
  199.                     break;
  200.                 }
  201.             }
  202.         } catch (ClassNotFoundException ex) {
  203.             java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  204.         } catch (InstantiationException ex) {
  205.             java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  206.         } catch (IllegalAccessException ex) {
  207.             java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  208.         } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  209.             java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  210.         }
  211.         //</editor-fold>
  212.  
  213.         /* Create and display the form */
  214.         java.awt.EventQueue.invokeLater(new Runnable() {
  215.             public void run() {
  216.                 new Login().setVisible(true);
  217.             }
  218.         });
  219.     }
  220.  
  221.     // Variables declaration - do not modify                    
  222.     private javax.swing.JLabel jLabel1;
  223.     private javax.swing.JLabel jLabel2;
  224.     private javax.swing.JLabel jLabel3;
  225.     private javax.swing.JPanel jPanel1;
  226.     private javax.swing.JPasswordField jPassword;
  227.     private javax.swing.JButton jbtnExit;
  228.     private javax.swing.JButton jbtnLogin;
  229.     private javax.swing.JButton jbtnReset;
  230.     private javax.swing.JTextField jtxtUserName;
  231.     // End of variables declaration                  
  232.    
  233.     private void systemExit()
  234.    {
  235.    WindowEvent winCloseing = new WindowEvent(this,WindowEvent.WINDOW_CLOSING);
  236.    }
  237. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement