PageRenderTime 63ms CodeModel.GetById 41ms RepoModel.GetById 1ms app.codeStats 0ms

/src/edu/esprit/tunisiamall/gui/LoginChoiceGUI.java

https://gitlab.com/Snizer/PI-DEV-TUNISIAMALL3A6-JAVA
Java | 274 lines | 186 code | 53 blank | 35 comment | 7 complexity | 08676655b755216a9e82411032cf5cb0 MD5 | raw file
  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 edu.esprit.tunisiamall.gui;
  7. import edu.esprit.tunisiamall.gui.LoginGUI;
  8. import edu.esprit.tunisiamall.gui.LoginQRcodeGUI;
  9. import edu.esprit.tunisiamall.technique.DataSource;
  10. import edu.esprit.tunisiamall.entities.Login;
  11. import edu.esprit.tunisiamall.dao.classes.LoginDAO;
  12. import edu.esprit.tunisiamall.entities.Produit;
  13. import edu.esprit.tunisiamall.gui.ResponsableEnseigneGUI;
  14. import org.opencv.core.Core;
  15. import edu.esprit.tunisiamall.technique.DataSource;
  16. import java.awt.Component;
  17. import java.awt.Graphics;
  18. import java.io.File;
  19. import java.util.logging.Level;
  20. import java.util.logging.Logger;
  21. import javax.swing.Icon;
  22. import javax.swing.ImageIcon;
  23. /**
  24. *
  25. * @author Safwene
  26. */
  27. public class LoginChoiceGUI extends javax.swing.JFrame {
  28. /**
  29. * Creates new form LoginGUI
  30. */
  31. public LoginChoiceGUI() {
  32. initComponents();
  33. this.setTitle("LOGIN");
  34. this.HelpjLabel.setText("");
  35. this.setResizable(false);
  36. this.setLocationRelativeTo(this);
  37. this.setVisible(true);
  38. this.getConnectionDB();
  39. this.DessinerBesoinDaide("Pas Encore Inscrit ?",40);
  40. this.LoginUsernamejButton.setEnabled(true);
  41. this.QRCodejButton.setEnabled(true);
  42. }
  43. void getConnectionDB(){
  44. try {
  45. this.DBconnectionjLabel.setIcon(new ImageIcon("src/edu/esprit/tunisiamall/images/Database-echec-icon.png"));
  46. this.LoginUsernamejButton.setEnabled(false);
  47. this.QRCodejButton.setEnabled(false);
  48. Thread.sleep(1000);
  49. if (DataSource.getInstance() != null){
  50. this.DBconnectionjLabel.setIcon(new ImageIcon("src/edu/esprit/tunisiamall/images/Database-Accept-icon.png"));
  51. }
  52. else {
  53. this.DBconnectionjLabel.setIcon(new ImageIcon("src/edu/esprit/tunisiamall/images/Database-echec-icon.png"));
  54. }
  55. } catch (InterruptedException ex) {
  56. Logger.getLogger(LoginChoiceGUI.class.getName()).log(Level.SEVERE, null, ex);
  57. }
  58. }
  59. public void DessinerBesoinDaide(String mot, int sleep){
  60. for (int i=0;i<mot.length();i++){
  61. try {
  62. String word ="";
  63. for (int j=0;j<=i;j++){
  64. word += mot.charAt(j);
  65. }
  66. this.HelpjLabel.setText(word);
  67. Thread.sleep(sleep);
  68. } catch (InterruptedException ex) {
  69. Logger.getLogger(LoginChoiceGUI.class.getName()).log(Level.SEVERE, null, ex);
  70. }
  71. }
  72. }
  73. /**
  74. * This method is called from within the constructor to initialize the form.
  75. * WARNING: Do NOT modify this code. The content of this method is always
  76. * regenerated by the Form Editor.
  77. */
  78. @SuppressWarnings("unchecked")
  79. // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  80. private void initComponents() {
  81. jLabelLogo = new javax.swing.JLabel();
  82. QRCodejButton = new javax.swing.JButton();
  83. LoginUsernamejButton = new javax.swing.JButton();
  84. QRCodeUsernameLogojLabel = new javax.swing.JLabel();
  85. DBconnectionjLabel = new javax.swing.JLabel();
  86. HelpjLabel = new javax.swing.JLabel();
  87. setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  88. setResizable(false);
  89. jLabelLogo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/edu/esprit/tunisiamall/images/logo-Tunisia-Mall.jpg"))); // NOI18N
  90. QRCodejButton.setText("QRcode");
  91. QRCodejButton.addActionListener(new java.awt.event.ActionListener() {
  92. public void actionPerformed(java.awt.event.ActionEvent evt) {
  93. QRCodejButtonActionPerformed(evt);
  94. }
  95. });
  96. LoginUsernamejButton.setText("Login & password");
  97. LoginUsernamejButton.addActionListener(new java.awt.event.ActionListener() {
  98. public void actionPerformed(java.awt.event.ActionEvent evt) {
  99. LoginUsernamejButtonActionPerformed(evt);
  100. }
  101. });
  102. QRCodeUsernameLogojLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/edu/esprit/tunisiamall/images/login_icon.png"))); // NOI18N
  103. DBconnectionjLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/edu/esprit/tunisiamall/images/Database-Accept-icon.png"))); // NOI18N
  104. HelpjLabel.setText("Besoin d'aide ?");
  105. HelpjLabel.addMouseListener(new java.awt.event.MouseAdapter() {
  106. public void mouseClicked(java.awt.event.MouseEvent evt) {
  107. HelpjLabelMouseClicked(evt);
  108. }
  109. });
  110. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  111. getContentPane().setLayout(layout);
  112. layout.setHorizontalGroup(
  113. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  114. .addGroup(layout.createSequentialGroup()
  115. .addContainerGap()
  116. .addComponent(DBconnectionjLabel)
  117. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  118. .addGroup(layout.createSequentialGroup()
  119. .addGap(76, 76, 76)
  120. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  121. .addComponent(LoginUsernamejButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  122. .addComponent(QRCodejButton, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE))
  123. .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  124. .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  125. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  126. .addComponent(HelpjLabel)
  127. .addContainerGap())))
  128. .addGroup(layout.createSequentialGroup()
  129. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  130. .addGroup(layout.createSequentialGroup()
  131. .addGap(82, 82, 82)
  132. .addComponent(jLabelLogo))
  133. .addGroup(layout.createSequentialGroup()
  134. .addGap(141, 141, 141)
  135. .addComponent(QRCodeUsernameLogojLabel)))
  136. .addContainerGap(83, Short.MAX_VALUE))
  137. );
  138. layout.setVerticalGroup(
  139. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  140. .addGroup(layout.createSequentialGroup()
  141. .addComponent(jLabelLogo)
  142. .addGap(18, 18, 18)
  143. .addComponent(QRCodeUsernameLogojLabel)
  144. .addGap(18, 18, 18)
  145. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  146. .addGroup(layout.createSequentialGroup()
  147. .addComponent(LoginUsernamejButton)
  148. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  149. .addComponent(QRCodejButton)
  150. .addContainerGap(36, Short.MAX_VALUE))
  151. .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  152. .addGap(0, 0, Short.MAX_VALUE)
  153. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  154. .addComponent(HelpjLabel)
  155. .addComponent(DBconnectionjLabel))
  156. .addGap(8, 8, 8))))
  157. );
  158. pack();
  159. }// </editor-fold>//GEN-END:initComponents
  160. private void LoginUsernamejButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LoginUsernamejButtonActionPerformed
  161. this.setVisible(false);
  162. LoginGUI loginGUI = new LoginGUI();
  163. loginGUI.setVisible(true);
  164. }//GEN-LAST:event_LoginUsernamejButtonActionPerformed
  165. private void QRCodejButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_QRCodejButtonActionPerformed
  166. this.setVisible(false);
  167. LoginQRcodeGUI loginQRcodeGUI = new LoginQRcodeGUI();
  168. loginQRcodeGUI.setVisible(true);
  169. }//GEN-LAST:event_QRCodejButtonActionPerformed
  170. private void HelpjLabelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_HelpjLabelMouseClicked
  171. this.setVisible(false);
  172. iNSCRIPTION insc= new iNSCRIPTION();
  173. insc.setVisible(true);
  174. }//GEN-LAST:event_HelpjLabelMouseClicked
  175. /**
  176. * @param args the command line arguments
  177. */
  178. public static void main(String args[]) {
  179. /* Set the Nimbus look and feel */
  180. //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  181. /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  182. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  183. */
  184. try {
  185. for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  186. if ("Nimbus".equals(info.getName())) {
  187. javax.swing.UIManager.setLookAndFeel(info.getClassName());
  188. break;
  189. }
  190. }
  191. } catch (ClassNotFoundException ex) {
  192. java.util.logging.Logger.getLogger(LoginChoiceGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  193. } catch (InstantiationException ex) {
  194. java.util.logging.Logger.getLogger(LoginChoiceGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  195. } catch (IllegalAccessException ex) {
  196. java.util.logging.Logger.getLogger(LoginChoiceGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  197. } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  198. java.util.logging.Logger.getLogger(LoginChoiceGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  199. }
  200. //</editor-fold>
  201. // System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
  202. //</editor-fold>
  203. //</editor-fold>
  204. // System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
  205. //</editor-fold>
  206. /* Create and display the form */
  207. java.awt.EventQueue.invokeLater(new Runnable() {
  208. public void run() {
  209. new LoginChoiceGUI();
  210. }
  211. });
  212. }
  213. // Variables declaration - do not modify//GEN-BEGIN:variables
  214. private javax.swing.JLabel DBconnectionjLabel;
  215. private javax.swing.JLabel HelpjLabel;
  216. private javax.swing.JButton LoginUsernamejButton;
  217. private javax.swing.JLabel QRCodeUsernameLogojLabel;
  218. private javax.swing.JButton QRCodejButton;
  219. private javax.swing.JLabel jLabelLogo;
  220. // End of variables declaration//GEN-END:variables
  221. }