Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * 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 Logins;
- import javax.swing.JOptionPane;
- import java.awt.Toolkit;
- import java.awt.event.WindowEvent;
- import Logins.Login_s;
- /**
- *
- * @author ASUS-PC
- */
- public class Login extends javax.swing.JFrame {
- /**
- * Creates new form Login
- */
- public Login() {
- initComponents();
- }
- /**
- * 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() {
- jPanel1 = new javax.swing.JPanel();
- jLabel2 = new javax.swing.JLabel();
- jLabel3 = new javax.swing.JLabel();
- jtxtUserName = new javax.swing.JTextField();
- jPassword = new javax.swing.JPasswordField();
- jbtnLogin = new javax.swing.JButton();
- jbtnReset = new javax.swing.JButton();
- jbtnExit = new javax.swing.JButton();
- jLabel1 = new javax.swing.JLabel();
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0), 30));
- jLabel2.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
- jLabel2.setText("Username");
- jLabel3.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
- jLabel3.setText("Password");
- jtxtUserName.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
- jtxtUserName.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0), 4));
- jPassword.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
- jPassword.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0), 4));
- jbtnLogin.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
- jbtnLogin.setText("Login");
- jbtnLogin.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jbtnLoginActionPerformed(evt);
- }
- });
- jbtnReset.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
- jbtnReset.setText("Reset");
- jbtnReset.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jbtnResetActionPerformed(evt);
- }
- });
- jbtnExit.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
- jbtnExit.setText("Exit");
- jbtnExit.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jbtnExitActionPerformed(evt);
- }
- });
- 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()
- .addContainerGap()
- .addComponent(jbtnLogin)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(jbtnReset))
- .addGroup(jPanel1Layout.createSequentialGroup()
- .addGap(41, 41, 41)
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
- .addComponent(jLabel3)
- .addComponent(jLabel2))))
- .addGap(7, 7, 7)
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
- .addGroup(jPanel1Layout.createSequentialGroup()
- .addComponent(jbtnExit, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(213, 213, 213))
- .addComponent(jtxtUserName, javax.swing.GroupLayout.PREFERRED_SIZE, 360, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addComponent(jPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 360, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- );
- jPanel1Layout.setVerticalGroup(
- jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel1Layout.createSequentialGroup()
- .addGap(20, 20, 20)
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jtxtUserName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jLabel2))
- .addGap(31, 31, 31)
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
- .addComponent(jPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jLabel3))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 101, Short.MAX_VALUE)
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jbtnLogin)
- .addComponent(jbtnReset)
- .addComponent(jbtnExit))
- .addGap(28, 28, 28))
- );
- jLabel1.setFont(new java.awt.Font("Tahoma", 1, 48)); // NOI18N
- jLabel1.setText(" Login System");
- jLabel1.setVerticalAlignment(javax.swing.SwingConstants.TOP);
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 485, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGap(0, 29, Short.MAX_VALUE))
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addGap(31, 31, 31)
- .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(20, 20, 20))
- );
- pack();
- }// </editor-fold>
- private void jbtnExitActionPerformed(java.awt.event.ActionEvent evt) {
- System.exit(0);
- }
- private void jbtnResetActionPerformed(java.awt.event.ActionEvent evt) {
- jtxtUserName.setText(null);
- jPassword.setText(null);
- }
- private void jbtnLoginActionPerformed(java.awt.event.ActionEvent evt) {
- String password = jPassword.getText();
- String username = jtxtUserName.getText();
- if (password.contains("mit")&&(username.contains("mithon")))
- {
- jtxtUserName.setText(null);
- jPassword.setText(null);
- systemExit();
- Login_s Info = new Login_s();
- Info.setVisible(true);
- }
- else
- {
- JOptionPane.showMessageDialog(null,"Invalid Login Details", "Login Error", JOptionPane.ERROR_MESSAGE);
- jPassword.setText(null);
- jtxtUserName.setText(null);
- }
- }
- /**
- * @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.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);
- }
- //</editor-fold>
- /* Create and display the form */
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- new Login().setVisible(true);
- }
- });
- }
- // Variables declaration - do not modify
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
- private javax.swing.JLabel jLabel3;
- private javax.swing.JPanel jPanel1;
- private javax.swing.JPasswordField jPassword;
- private javax.swing.JButton jbtnExit;
- private javax.swing.JButton jbtnLogin;
- private javax.swing.JButton jbtnReset;
- private javax.swing.JTextField jtxtUserName;
- // End of variables declaration
- private void systemExit()
- {
- WindowEvent winCloseing = new WindowEvent(this,WindowEvent.WINDOW_CLOSING);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement