
if-statement se detiene sin hacer nada
Publicado por Josefa (3 intervenciones) el 30/03/2022 12:19:42
Estoy escribiendo un programa para la escuela y lo estoy haciendo en Java Swing. Mi problema ahora es que una vez que hago clic en el botón, lee el texto de JTextArea, lo imprime, pero mi declaración if termina como comienza. ¿Qué estoy haciendo mal?
El siguiente código está escrito en el programa y la declaración if que compara jTextArea1.getText() con otros valores se detiene cuando comienza. Quiero insertar los Objetos en un orden de lo que es el Recuento de las variables.
El siguiente código está escrito en el programa y la declaración if que compara jTextArea1.getText() con otros valores se detiene cuando comienza. Quiero insertar los Objetos en un orden de lo que es el Recuento de las variables.
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
public void jButton1_ActionPerformed(ActionEvent evt) {
String textFieldValue = jTextField1.getText();
si (modelo de tabla. getRowCount() > 0) {
for (int i = tableModel.getRowCount() - 1; i > -1; i--) {
modelo de tabla.removeRow(i);
}
}
System.out.println(textFieldValue);
jTextArea1.setText(jTextField1.getText());
if(jTextField1.getText() == "schwarz" || jTextField1.getText() == "braune Tiere" || jTextField1.getText() == "schwarze Tiere" || jTextField1.getText() == "braun" ) {
if(caninchenCount>katzeCount && kaninchenCount>hundCount) {
tableModel.insertRow(0, nuevo Objeto[] { "Kaninchen" });
if(katzeCount>hundCount) {
tableModel.insertRow(0, nuevo Objeto[] { "Katze" });
tableModel.insertRow(0, nuevo Objeto[] { "Hund" });
} demás {
tableModel.insertRow(0, nuevo Objeto[] { "Hund" });
tableModel.insertRow(0, nuevo Objeto[] { "Katze" });
}
} else if (katzeCount>kaninchenCount && katzeCount>hundCount) {
tableModel2.insertRow(0, nuevo Objeto[] { "Katze" });
if(kaninchenCount>hundCount) {
tableModel.insertRow(0, nuevo Objeto[] { "Kaninchen" });
tableModel.insertRow(0, nuevo Objeto[] { "Hund" });
} demás {
tableModel.insertRow(0, nuevo Objeto[] { "Hund" });
tableModel.insertRow(0, nuevo Objeto[] { "Kaninchen" });
}
} else if(CuentaCentros>CuentaKaninchen && CuentaCuentas>CuentaKatze) {
tableModel.insertRow(0, nuevo Objeto[] { "Hund" });
if(kaninchenCuenta>katzeCuenta) {
tableModel.insertRow(0, nuevo Objeto[] { "Kaninchen" });
tableModel.insertRow(0, nuevo Objeto[] { "Katze" });
} demás {
tableModel.insertRow(0, nuevo Objeto[] { "Katze" });
tableModel.insertRow(0, nuevo Objeto[] { "Kaninchen" });
}
}
// agregar (jTable2ScrollPane);
//establecerVisible(verdadero);
}
}
Valora esta pregunta


0