Advertisement
Sajib_Ahmed

Untitled

Apr 9th, 2019
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.78 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 RailWayManegment;
  7.  
  8. import javax.swing.JOptionPane;
  9. import RailWayManegment.Rail01;
  10. /**
  11. *
  12. * @author sajib
  13. */
  14. public class login extends javax.swing.JFrame {
  15.  
  16. /**
  17. * Creates new form login
  18. */
  19. public login() {
  20. initComponents();
  21. }
  22.  
  23. /**
  24. * This method is called from within the constructor to initialize the form.
  25. * WARNING: Do NOT modify this code. The content of this method is always
  26. * regenerated by the Form Editor.
  27. */
  28. @SuppressWarnings("unchecked")
  29. // <editor-fold defaultstate="collapsed" desc="Generated Code">
  30. private void initComponents() {
  31.  
  32. jLabel1 = new javax.swing.JLabel();
  33. username = new javax.swing.JTextField();
  34. jLabel2 = new javax.swing.JLabel();
  35. pass = new javax.swing.JPasswordField();
  36. login = new javax.swing.JButton();
  37. jButton2 = new javax.swing.JButton();
  38. jButton3 = new javax.swing.JButton();
  39.  
  40. setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  41.  
  42. jLabel1.setText("UserName");
  43.  
  44. username.addActionListener(new java.awt.event.ActionListener() {
  45. public void actionPerformed(java.awt.event.ActionEvent evt) {
  46. usernameActionPerformed(evt);
  47. }
  48. });
  49.  
  50. jLabel2.setText("Password");
  51.  
  52. pass.addActionListener(new java.awt.event.ActionListener() {
  53. public void actionPerformed(java.awt.event.ActionEvent evt) {
  54. passActionPerformed(evt);
  55. }
  56. });
  57.  
  58. login.setText("Login");
  59. login.addActionListener(new java.awt.event.ActionListener() {
  60. public void actionPerformed(java.awt.event.ActionEvent evt) {
  61. loginActionPerformed(evt);
  62. }
  63. });
  64.  
  65. jButton2.setText("Cancel");
  66. jButton2.addActionListener(new java.awt.event.ActionListener() {
  67. public void actionPerformed(java.awt.event.ActionEvent evt) {
  68. jButton2ActionPerformed(evt);
  69. }
  70. });
  71.  
  72. jButton3.setText("Reset");
  73.  
  74. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  75. getContentPane().setLayout(layout);
  76. layout.setHorizontalGroup(
  77. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  78. .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  79. .addGap(40, 40, 40)
  80. .addComponent(jButton3)
  81. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  82. .addComponent(jButton2)
  83. .addGap(40, 40, 40))
  84. .addGroup(layout.createSequentialGroup()
  85. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  86. .addGroup(layout.createSequentialGroup()
  87. .addGap(48, 48, 48)
  88. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  89. .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
  90. .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE))
  91. .addGap(44, 44, 44)
  92. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  93. .addComponent(username)
  94. .addComponent(pass, javax.swing.GroupLayout.DEFAULT_SIZE, 127, Short.MAX_VALUE)))
  95. .addGroup(layout.createSequentialGroup()
  96. .addGap(195, 195, 195)
  97. .addComponent(login)))
  98. .addContainerGap(147, Short.MAX_VALUE))
  99. );
  100. layout.setVerticalGroup(
  101. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  102. .addGroup(layout.createSequentialGroup()
  103. .addGap(30, 30, 30)
  104. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  105. .addComponent(jLabel1)
  106. .addComponent(username, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  107. .addGap(18, 18, 18)
  108. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  109. .addComponent(jLabel2)
  110. .addComponent(pass, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  111. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 79, Short.MAX_VALUE)
  112. .addComponent(login)
  113. .addGap(56, 56, 56)
  114. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  115. .addComponent(jButton2)
  116. .addComponent(jButton3))
  117. .addGap(31, 31, 31))
  118. );
  119.  
  120. pack();
  121. }// </editor-fold>
  122.  
  123. private void usernameActionPerformed(java.awt.event.ActionEvent evt) {
  124. username.setText(username.getText());
  125. }
  126.  
  127. private void passActionPerformed(java.awt.event.ActionEvent evt) {
  128. pass.setText(pass.getText());
  129. }
  130.  
  131. private void loginActionPerformed(java.awt.event.ActionEvent evt) {
  132. String username1 = username.getText();
  133. String pass1 = pass.getText();
  134. if (pass1.contains("12345") && (username1.contains("p"))) {
  135. username.setText(null);
  136. pass.setText(null);
  137.  
  138. Rail01 info = new Rail01();
  139. //Rail01.setVisible(true);
  140.  
  141. } else {
  142. JOptionPane.showMessageDialog(null, "Invalid Login Details", "ERROR!", JOptionPane.ERROR_MESSAGE);
  143. username.setText(null);
  144. pass.setText(null);
  145.  
  146. }
  147. }
  148.  
  149. private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
  150. // TODO add your handling code here:
  151. }
  152.  
  153. /**
  154. * @param args the command line arguments
  155. */
  156. public static void main(String args[]) {
  157. /* Set the Nimbus look and feel */
  158. //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  159. /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  160. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  161. */
  162. try {
  163. for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  164. if ("Nimbus".equals(info.getName())) {
  165. javax.swing.UIManager.setLookAndFeel(info.getClassName());
  166. break;
  167. }
  168. }
  169. } catch (ClassNotFoundException ex) {
  170. java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  171. } catch (InstantiationException ex) {
  172. java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  173. } catch (IllegalAccessException ex) {
  174. java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  175. } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  176. java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  177. }
  178. //</editor-fold>
  179.  
  180. /* Create and display the form */
  181. java.awt.EventQueue.invokeLater(new Runnable() {
  182. public void run() {
  183. new login().setVisible(true);
  184. }
  185. });
  186. }
  187.  
  188. // Variables declaration - do not modify
  189. private javax.swing.JButton jButton2;
  190. private javax.swing.JButton jButton3;
  191. private javax.swing.JLabel jLabel1;
  192. private javax.swing.JLabel jLabel2;
  193. private javax.swing.JButton login;
  194. private javax.swing.JPasswordField pass;
  195. private javax.swing.JTextField username;
  196. // End of variables declaration
  197. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement