PageRenderTime 45ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/src/tocomfome/src/TelaLogin.java

https://gitlab.com/Zero101010/EP2
Java | 189 lines | 138 code | 20 blank | 31 comment | 3 complexity | a7d6fbd3ce8232159da7d2bd66d9c5d5 MD5 | raw file
  1. import javax.swing.JOptionPane;
  2. /*
  3. * To change this license header, choose License Headers in Project Properties.
  4. * To change this template file, choose Tools | Templates
  5. * and open the template in the editor.
  6. */
  7. /**
  8. *
  9. * @author zero101010
  10. */
  11. public class TelaLogin extends javax.swing.JFrame {
  12. /**
  13. * Creates new form TelaLogin
  14. */
  15. public TelaLogin() {
  16. initComponents();
  17. }
  18. /**
  19. * This method is called from within the constructor to initialize the form.
  20. * WARNING: Do NOT modify this code. The content of this method is always
  21. * regenerated by the Form Editor.
  22. */
  23. @SuppressWarnings("unchecked")
  24. // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  25. private void initComponents() {
  26. jPanel1 = new javax.swing.JPanel();
  27. jLabel1 = new javax.swing.JLabel();
  28. jLabel2 = new javax.swing.JLabel();
  29. tfLogin = new javax.swing.JTextField();
  30. btEntrar = new javax.swing.JButton();
  31. btCancelar = new javax.swing.JButton();
  32. jLabel3 = new javax.swing.JLabel();
  33. tfSenha = new javax.swing.JPasswordField();
  34. setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  35. jLabel1.setText("Login:");
  36. jLabel2.setText("Senha:");
  37. btEntrar.setText("Entrar");
  38. btEntrar.addActionListener(new java.awt.event.ActionListener() {
  39. public void actionPerformed(java.awt.event.ActionEvent evt) {
  40. btEntrarActionPerformed(evt);
  41. }
  42. });
  43. btCancelar.setText("Cancelar");
  44. btCancelar.addActionListener(new java.awt.event.ActionListener() {
  45. public void actionPerformed(java.awt.event.ActionEvent evt) {
  46. btCancelarActionPerformed(evt);
  47. }
  48. });
  49. jLabel3.setText("Digite seu login e senha:");
  50. javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
  51. jPanel1.setLayout(jPanel1Layout);
  52. jPanel1Layout.setHorizontalGroup(
  53. jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  54. .addGroup(jPanel1Layout.createSequentialGroup()
  55. .addGap(106, 106, 106)
  56. .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  57. .addGroup(jPanel1Layout.createSequentialGroup()
  58. .addComponent(jLabel3)
  59. .addGap(0, 0, Short.MAX_VALUE))
  60. .addGroup(jPanel1Layout.createSequentialGroup()
  61. .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
  62. .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
  63. .addComponent(btEntrar, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
  64. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 69, Short.MAX_VALUE)
  65. .addComponent(btCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE))
  66. .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
  67. .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  68. .addComponent(jLabel1)
  69. .addComponent(jLabel2))
  70. .addGap(33, 33, 33)
  71. .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  72. .addComponent(tfLogin, javax.swing.GroupLayout.DEFAULT_SIZE, 167, Short.MAX_VALUE)
  73. .addComponent(tfSenha))))
  74. .addContainerGap(33, Short.MAX_VALUE))))
  75. );
  76. jPanel1Layout.setVerticalGroup(
  77. jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  78. .addGroup(jPanel1Layout.createSequentialGroup()
  79. .addGap(38, 38, 38)
  80. .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
  81. .addGap(32, 32, 32)
  82. .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  83. .addComponent(jLabel1)
  84. .addComponent(tfLogin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  85. .addGap(38, 38, 38)
  86. .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  87. .addComponent(jLabel2)
  88. .addComponent(tfSenha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  89. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 49, Short.MAX_VALUE)
  90. .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  91. .addComponent(btEntrar, javax.swing.GroupLayout.DEFAULT_SIZE, 50, Short.MAX_VALUE)
  92. .addComponent(btCancelar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  93. .addContainerGap())
  94. );
  95. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  96. getContentPane().setLayout(layout);
  97. layout.setHorizontalGroup(
  98. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  99. .addGroup(layout.createSequentialGroup()
  100. .addContainerGap()
  101. .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  102. .addContainerGap())
  103. );
  104. layout.setVerticalGroup(
  105. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  106. .addGroup(layout.createSequentialGroup()
  107. .addGap(22, 22, 22)
  108. .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  109. .addContainerGap())
  110. );
  111. pack();
  112. setLocationRelativeTo(null);
  113. }// </editor-fold>//GEN-END:initComponents
  114. private void btEntrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btEntrarActionPerformed
  115. if(tfLogin.getText().equals("Funcionario")&& tfSenha.getText().equals("1234")){
  116. // JOptionPane.showMessageDialog(null,"Acesso permitido");
  117. new Menu().setVisible(true);
  118. this.dispose();
  119. }else{
  120. JOptionPane.showMessageDialog(null,"Acesso negado");
  121. }
  122. }//GEN-LAST:event_btEntrarActionPerformed
  123. private void btCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btCancelarActionPerformed
  124. System.exit(0);
  125. }//GEN-LAST:event_btCancelarActionPerformed
  126. /**
  127. * @param args the command line arguments
  128. */
  129. public static void main(String args[]) {
  130. /* Set the Nimbus look and feel */
  131. //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  132. /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  133. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  134. */
  135. try {
  136. for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  137. if ("Nimbus".equals(info.getName())) {
  138. javax.swing.UIManager.setLookAndFeel(info.getClassName());
  139. break;
  140. }
  141. }
  142. } catch (ClassNotFoundException ex) {
  143. java.util.logging.Logger.getLogger(TelaLogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  144. } catch (InstantiationException ex) {
  145. java.util.logging.Logger.getLogger(TelaLogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  146. } catch (IllegalAccessException ex) {
  147. java.util.logging.Logger.getLogger(TelaLogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  148. } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  149. java.util.logging.Logger.getLogger(TelaLogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  150. }
  151. //</editor-fold>
  152. /* Create and display the form */
  153. java.awt.EventQueue.invokeLater(new Runnable() {
  154. public void run() {
  155. new TelaLogin().setVisible(true);
  156. }
  157. });
  158. }
  159. // Variables declaration - do not modify//GEN-BEGIN:variables
  160. private javax.swing.JButton btCancelar;
  161. private javax.swing.JButton btEntrar;
  162. private javax.swing.JLabel jLabel1;
  163. private javax.swing.JLabel jLabel2;
  164. private javax.swing.JLabel jLabel3;
  165. private javax.swing.JPanel jPanel1;
  166. private javax.swing.JTextField tfLogin;
  167. private javax.swing.JPasswordField tfSenha;
  168. // End of variables declaration//GEN-END:variables
  169. }