Fill a JTable with a three-dimensional array?

0

I have a three-dimensional arrangement in Java :

arreglo[numerodetablas][][]

The first dimension determines the number of tables and the others are the dimensions of each table. How to program this in tables JTable ?

    
asked by Ck12 14.03.2017 в 01:30
source

1 answer

1

You should do it with a for per dimension. The first one would generate the tables and then the other two dimensions the values to fill that table.

It could be something like this:

Object [][][] array = new Object[5][10][10];
// Suponemos que el array tiene valores

for(int n = 0; n < 5; n++){
    Vector model = new Vector();
    Vector row = new Vector();

    for(int i = 0; i < 10; i++){
        row = new Vector();

        for(int j = 0; j < 10; j++){
            row.add(array[n][i][j]);
        }

        model.add(row);
    }

    JTable table = new JTable(model);
    // Tabla creada para cada dimension n del array tridimensional
}
    
answered by 14.03.2017 в 08:23