
Fallo en Array "java.lang.ArrayIndexOutOfBoundsException: "X" > 0"
Publicado por Diego (3 intervenciones) el 10/01/2016 22:35:29
Hola a todos, estoy trabajando en un pequeño codigo en java y resulta que cada vez que guardo valores en una tabla va todo bien...y cuando veo los datos en otro formulario tambien va bien...pero luego cuando vuelvo a introducir mas datos para insertar y vuelvo a ver la tabla de datos me salta un error de java.lang.ArrayIndexOutOfBoundsException: X > 0
y no se como puedo solucionar este problema, muchas gracias por vuestra ayuda.. estos son los codigos de los botones
BOTON GUARDAR
BOTON MOSTRAR LISTA
PANEL DE LA TABLA
Un Saludo y gracias
y no se como puedo solucionar este problema, muchas gracias por vuestra ayuda.. estos son los codigos de los botones
BOTON GUARDAR
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
private void bntInsertarActionPerformed(java.awt.event.ActionEvent evt) {
float ingreso = 0;
String fecha = jtxtFecha.getText();
if (jtxtIngreso.getText().length() == 0) {
jtxtIngreso.setText("0");
} else {
ingreso = Float.parseFloat(jtxtIngreso.getText());
}
String moneda = (String) jcbMoneda.getSelectedItem();
String motivo = jtxtMotivo.getText();
Ingreso i = new Ingreso(fecha, ingreso, moneda, motivo);
lc.add(i);
}
BOTON MOSTRAR LISTA
1
2
listadoIngresos newFrameIngresos = new listadoIngresos();
newFrameIngresos.setVisible(true);
PANEL DE LA TABLA
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
import static principal.PanelIngreso.lc;
public class listadoIngresos extends javax.swing.JFrame {
static DefaultTableModel modelo;
static int con = 0;
public listadoIngresos() {
initComponents();
cargaInterfaz();
Ingreso i;
for (Object lc1 : lc) {
i = (Ingreso) lc1;
MostrarDatosIngresos(i);
}
}
public static void cargaInterfaz() {
String[][] x = {};
String[] columnas = {"fecha", "Cantidad", "moneda", "motivo"};
modelo = new DefaultTableModel(x, columnas);
tblIngresos.setModel(modelo);
}
public static void MostrarDatosIngresos(Ingreso i) {
modelo.insertRow(con, new Object[]{});
modelo.setValueAt(i.getFecha(), con, 0);
modelo.setValueAt(i.getIngreso(), con, 1);
modelo.setValueAt(i.getMoneda(), con, 2);
modelo.setValueAt(i.getMotivoIngreso(), con, 3);
con++;
}
Valora esta pregunta


0