-
Notifications
You must be signed in to change notification settings - Fork 0
/
CADASTRO.java
155 lines (123 loc) · 5.54 KB
/
CADASTRO.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
package main;
import Mongo.conectaMongo;
/**
*
* @author 23162799
*/
public class CADASTRO extends javax.swing.JFrame {
/**
* Creates new form CADASTRO
*/
public CADASTRO() {
initComponents();
setSize(599, 535);
// Centraliza a janela na tela
setLocationRelativeTo(null);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
CadUsuario = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
CadSenha = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
jButton2 = new javax.swing.JButton();
jButton1 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
getContentPane().setLayout(null);
getContentPane().add(jLabel1);
jLabel1.setBounds(104, 6, 203, 25);
jLabel2.setText("Usuario");
getContentPane().add(jLabel2);
jLabel2.setBounds(23, 52, 40, 16);
CadUsuario.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CadUsuarioActionPerformed(evt);
}
});
getContentPane().add(CadUsuario);
CadUsuario.setBounds(190, 210, 204, 22);
jLabel3.setText("Senha");
getContentPane().add(jLabel3);
jLabel3.setBounds(23, 92, 32, 16);
getContentPane().add(CadSenha);
CadSenha.setBounds(190, 290, 204, 22);
jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/LILITH_cadastro.png"))); // NOI18N
jLabel4.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
getContentPane().add(jLabel4);
jLabel4.setBounds(0, -10, 580, 520);
jButton2.setForeground(new java.awt.Color(255, 255, 255));
jButton2.setBorder(null);
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
getContentPane().add(jButton2);
jButton2.setBounds(20, 483, 120, 50);
jButton1.setForeground(new java.awt.Color(255, 255, 255));
jButton1.setBorder(null);
jButton1.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
getContentPane().add(jButton1);
jButton1.setBounds(394, 460, 180, 70);
pack();
}// </editor-fold>//GEN-END:initComponents
private void CadUsuarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CadUsuarioActionPerformed
}//GEN-LAST:event_CadUsuarioActionPerformed
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// Define a cor de fundo do jButton1 como preto com transparência
jButton1.setBackground(new java.awt.Color(0, 0, 0, 1));
// Cria uma instância da classe conectaMongo para interagir com o MongoDB
conectaMongo conn = new conectaMongo();
// Obtém o nome de usuário e senha dos campos de texto CadUsuario e CadSenha
String Usuario = CadUsuario.getText();
int Senha = Integer.parseInt(CadSenha.getText());
// Define um valor padrão para o score (pode ser ajustado conforme necessário)
int scorePadrao = 0;
// Insere os valores do usuário no banco de dados, incluindo o nome de usuário, senha e score padrão
conn.insertValues(Usuario, Senha, scorePadrao);
// Recupera e exibe os valores do banco de dados (se necessário)
conn.getValues();
// Cria uma instância da classe mainClass e torna-a visível
new mainClass().setVisible(true);
// Fecha a janela atual (dispose)
dispose();
}//GEN-LAST:event_jButton1ActionPerformed
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
// Define a cor de fundo do jButton2 como preto com transparência
jButton2.setBackground(new java.awt.Color(0, 0, 0, 1));
// Cria uma nova instância da classe mainClass e a torna visível
new mainClass().setVisible(true);
// Fecha a janela atual (dispose)
dispose();
}//GEN-LAST:event_jButton2ActionPerformed
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new CADASTRO().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JTextField CadSenha;
private javax.swing.JTextField CadUsuario;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
// End of variables declaration//GEN-END:variables
}