Advertisement
Guest User

Untitled

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