Ayuda con este botón para buscar
Publicado por Devastador (15 intervenciones) el 27/10/2020 23:27:12
En este botón guardo la información que necesito
Y con este que esta en otra clase recorro y busco mediante el dato ingresado en un textfield y lo comparo con los datos de carne que se encuentra en el array
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
private void saveActionPerformed(java.awt.event.ActionEvent evt) {
int numcorr = 0;
String n = name.getText();
String a = apellido.getText();
String c = carnet.getText();
String s = null;
if (masculino.isSelected()){
s = "Masculino";
}
else if (femenino.isSelected()){
s = "Femenino";
}
int e = Integer.parseInt(edad.getText());
String correo = mail.getText();
String facul = (String) facu.getSelectedItem().toString();
String talla = (String) size.getSelectedItem().toString();
String txtplay = textshirt.getText();
String mod = null;
if (caminadora.isSelected()){
mod = "Modalidad Caminadora";
}
else if (jardin.isSelected()){
mod = "Modalidad Jardin";
}
else if (otro.isSelected()){
mod = otrotxt.getText();
otrotxt.setText(" ");
}
float tiempcorr = 0;
if(n.equals("")){
JOptionPane.showMessageDialog(rootPane, "CAMPO OBLIGATORIO - Ingrese el Nombre del Corredor","Alerta",JOptionPane.WARNING_MESSAGE);}
else if(a.equals("")){
JOptionPane.showMessageDialog(rootPane, "CAMPO OBLIGATORIO - Ingrese el Apellido del Corredor","Alerta",JOptionPane.WARNING_MESSAGE);}
else if(c.equals("")){
JOptionPane.showMessageDialog(rootPane, "CAMPO OBLIGATORIO - Ingrese el Carné del Corredor","Alerta",JOptionPane.WARNING_MESSAGE);}
else if(s.equals("")){
JOptionPane.showMessageDialog(rootPane, "CAMPO OBLIGATORIO - Ingrese el Sexo del Corredor","Alerta",JOptionPane.WARNING_MESSAGE);}
else if(edad.equals("")){
JOptionPane.showMessageDialog(rootPane, "CAMPO OBLIGATORIO - Ingrese la Edad del Corredor","Alerta",JOptionPane.WARNING_MESSAGE);}
else if(correo.equals("")){
JOptionPane.showMessageDialog(rootPane, "CAMPO OBLIGATORIO - Ingrese el Correo del Corredor","Alerta",JOptionPane.WARNING_MESSAGE);}
else if(facul.equals("")){
JOptionPane.showMessageDialog(rootPane, "CAMPO OBLIGATORIO - Ingrese la Facultad del Corredor","Alerta",JOptionPane.WARNING_MESSAGE);}
else if(talla.equals("")){
JOptionPane.showMessageDialog(rootPane, "CAMPO OBLIGATORIO - Ingrese la talla del Corredor","Alerta",JOptionPane.WARNING_MESSAGE);}
else if(txtplay.equals("")){
JOptionPane.showMessageDialog(rootPane, "CAMPO OBLIGATORIO - Ingrese el Texto de la Playera del Corredor","Alerta",JOptionPane.WARNING_MESSAGE);}
else if(mod.equals("")){
JOptionPane.showMessageDialog(rootPane, "CAMPO OBLIGATORIO - Ingrese la Modalidad que Eligio el Corredor","Alerta",JOptionPane.WARNING_MESSAGE);}
else{
array[contador] = new inscritos (numcorr,n,a,c,s,e,correo,facul,talla,txtplay,mod,tiempcorr);
contador ++;
JOptionPane.showMessageDialog(rootPane, "Guardado correctamente","Notificación",JOptionPane.INFORMATION_MESSAGE);
name.setText(" ");
apellido.setText(" ");
carnet.setText(" ");
gruposexo.clearSelection();//borrar correo
edad.setText("");
mail.setText(" ");
facu.setSelectedItem(false);
size.setSelectedItem(false);
textshirt.setText(" ");
grupomod.clearSelection();
}
}
Y con este que esta en otra clase recorro y busco mediante el dato ingresado en un textfield y lo comparo con los datos de carne que se encuentra en el array
1
2
3
4
5
6
7
8
9
10
11
private void buscarActionPerformed(java.awt.event.ActionEvent evt) {
menuprincipal b1 = new menuprincipal ();
String buscador = busqueda.getText();
for (int i=0; i < b1.array.length; i++) {
if (buscador == b1.array[i].getCarne()) { <-- en esta línea me sale el error cuando le paso el debuger, el error es ATW-EventQueue-0
JOptionPane.showMessageDialog(rootPane, "El Corredor esta en el Registro","Notificación",JOptionPane.INFORMATION_MESSAGE);
} else {
JOptionPane.showMessageDialog(rootPane, "El Corredor no esta en el Registro","Alerta",JOptionPane.WARNING_MESSAGE);
}
}
}
Valora esta pregunta


0