Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.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 guilogin;
  7.  
  8. import javax.swing.JOptionPane;
  9.  
  10. /**
  11. *
  12. * @author Jaykn
  13. */
  14. public class LoginPageUI extends javax.swing.JFrame {
  15.  
  16. /**
  17. * Creates new form LoginPageUI
  18. */
  19. public LoginPageUI() {
  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. jPanel1 = new javax.swing.JPanel();
  33. jLabel1 = new javax.swing.JLabel();
  34. jLabel2 = new javax.swing.JLabel();
  35. Username1 = new javax.swing.JTextField();
  36. Password1 = new javax.swing.JPasswordField();
  37. Cancelbtn = new javax.swing.JToggleButton();
  38. jLabel4 = new javax.swing.JLabel();
  39. jButton1 = new javax.swing.JButton();
  40.  
  41. setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  42.  
  43. jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
  44.  
  45. jLabel1.setText("Username");
  46.  
  47. jLabel2.setText("Password");
  48.  
  49. Username1.addActionListener(new java.awt.event.ActionListener() {
  50. public void actionPerformed(java.awt.event.ActionEvent evt) {
  51. Username1ActionPerformed(evt);
  52. }
  53. });
  54.  
  55. Password1.addActionListener(new java.awt.event.ActionListener() {
  56. public void actionPerformed(java.awt.event.ActionEvent evt) {
  57. Password1ActionPerformed(evt);
  58. }
  59. });
  60.  
  61. Cancelbtn.setText("Cancel");
  62. Cancelbtn.addActionListener(new java.awt.event.ActionListener() {
  63. public void actionPerformed(java.awt.event.ActionEvent evt) {
  64. CancelbtnActionPerformed(evt);
  65. }
  66. });
  67.  
  68. jLabel4.setText("Software Login Screen");
  69.  
  70. jButton1.setText("Login");
  71. jButton1.addActionListener(new java.awt.event.ActionListener() {
  72. public void actionPerformed(java.awt.event.ActionEvent evt) {
  73. jButton1ActionPerformed(evt);
  74. }
  75. });
  76. jButton1.addKeyListener(new java.awt.event.KeyAdapter() {
  77. public void keyPressed(java.awt.event.KeyEvent evt) {
  78. jButton1KeyPressed(evt);
  79. }
  80. });
  81.  
  82. javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
  83. jPanel1.setLayout(jPanel1Layout);
  84. jPanel1Layout.setHorizontalGroup(
  85. jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  86. .addGroup(jPanel1Layout.createSequentialGroup()
  87. .addGap(94, 94, 94)
  88. .addComponent(jButton1)
  89. .addGap(48, 48, 48)
  90. .addComponent(Cancelbtn)
  91. .addContainerGap(120, Short.MAX_VALUE))
  92. .addGroup(jPanel1Layout.createSequentialGroup()
  93. .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  94. .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  95. .addComponent(jLabel1)
  96. .addComponent(jLabel2))
  97. .addGap(18, 18, 18)
  98. .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  99. .addComponent(Username1, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)
  100. .addComponent(Password1, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE))
  101. .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  102. .addGroup(jPanel1Layout.createSequentialGroup()
  103. .addGap(118, 118, 118)
  104. .addComponent(jLabel4)
  105. .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  106. );
  107. jPanel1Layout.setVerticalGroup(
  108. jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  109. .addGroup(jPanel1Layout.createSequentialGroup()
  110. .addGap(46, 46, 46)
  111. .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
  112. .addGap(17, 17, 17)
  113. .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  114. .addGroup(jPanel1Layout.createSequentialGroup()
  115. .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  116. .addComponent(Username1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  117. .addComponent(jLabel1))
  118. .addGap(18, 18, 18)
  119. .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  120. .addComponent(Password1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  121. .addComponent(jLabel2))
  122. .addContainerGap(112, Short.MAX_VALUE))
  123. .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
  124. .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  125. .addComponent(Cancelbtn)
  126. .addComponent(jButton1))
  127. .addGap(38, 38, 38))))
  128. );
  129.  
  130. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  131. getContentPane().setLayout(layout);
  132. layout.setHorizontalGroup(
  133. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  134. .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  135. );
  136. layout.setVerticalGroup(
  137. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  138. .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  139. );
  140.  
  141. pack();
  142. }// </editor-fold>
  143.  
  144. private void Username1ActionPerformed(java.awt.event.ActionEvent evt) {
  145. // TODO add your handling code here:
  146. }
  147.  
  148. private void CancelbtnActionPerformed(java.awt.event.ActionEvent evt) {
  149. // This exits the program
  150. System.exit(0);
  151. }
  152.  
  153.  
  154. private void Password1ActionPerformed(java.awt.event.ActionEvent evt) {
  155.  
  156.  
  157. }
  158.  
  159. private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
  160. // TODO add your handling code here:
  161. String password = Password1.getText();
  162. String username = Username1.getText();
  163.  
  164. if(password.contains("admin")&& username.contains ("admin")) {
  165. this.dispose();
  166. new Software().setVisible(true); // Main Form to show after the Login Form..
  167. Password1.setText("");
  168. Username1.setText(""); }
  169.  
  170.  
  171.  
  172. else
  173. JOptionPane.showMessageDialog(null, "Incorrect Login Details");
  174. Password1.setText("");
  175. Username1.setText("");
  176.  
  177.  
  178. }
  179.  
  180. private void jButton1KeyPressed(java.awt.event.KeyEvent evt) {
  181. // TODO add your handling code here:
  182. }
  183.  
  184. /**
  185. * @param args the command line arguments
  186. */
  187. public static void main(String args[]) {
  188. /* Set the Nimbus look and feel */
  189. //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  190. /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  191. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  192. */
  193. try {
  194. for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  195. if ("Nimbus".equals(info.getName())) {
  196. javax.swing.UIManager.setLookAndFeel(info.getClassName());
  197. break;
  198. }
  199. }
  200. } catch (ClassNotFoundException ex) {
  201. java.util.logging.Logger.getLogger(LoginPageUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  202. } catch (InstantiationException ex) {
  203. java.util.logging.Logger.getLogger(LoginPageUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  204. } catch (IllegalAccessException ex) {
  205. java.util.logging.Logger.getLogger(LoginPageUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  206. } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  207. java.util.logging.Logger.getLogger(LoginPageUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  208. }
  209. //</editor-fold>
  210.  
  211. /* Create and display the form */
  212. java.awt.EventQueue.invokeLater(new Runnable() {
  213. public void run() {
  214. new LoginPageUI().setVisible(true);
  215. }
  216. });
  217. }
  218.  
  219. // Variables declaration - do not modify
  220. private javax.swing.JToggleButton Cancelbtn;
  221. private javax.swing.JPasswordField Password1;
  222. private javax.swing.JTextField Username1;
  223. private javax.swing.JButton jButton1;
  224. private javax.swing.JLabel jLabel1;
  225. private javax.swing.JLabel jLabel2;
  226. private javax.swing.JLabel jLabel4;
  227. private javax.swing.JPanel jPanel1;
  228. // End of variables declaration
  229. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement