J'ai un nombre variable de tableaux bidimensionnels. La première dimension est variable, la seconde dimension est constante. -à-dire:Nombre variable de tableaux bidimensionnels dans un grand tableau
Object[][] array0 = {
{"tim", "sanchez", 34, 175.5, "bla", "blub", "[email protected]"},
{"alice", "smith", 42, 160.0, "la", "bub", "[email protected]"},
...
};
Object[][] array1 = {
{"john", "sdfs", 34, 15.5, "a", "bl", "[email protected]"},
{"joe", "smith", 42, 16.0, "a", "bub", "[email protected]"},
...
};
...
Object[][] arrayi = ...
Je générer ces tableaux avec une boucle for:
for (int i = 0; i < filter.length; i++) {
MyClass c = new MyClass(filter[i]);
//data = c.getData();
}
Où « filtre » est un autre tableau qui est rempli d'informations qui indique « MyClass » comment remplir le tableaux. "getData()" renvoie l'un des i nombre de tableaux.
Maintenant, j'ai juste besoin d'avoir tout dans un grand tableau bidimensionnel. i.e. .:
Object[][] arrayComplete = {
{"tim", "sanchez", 34, 175.5, "bla", "blub", "[email protected]"},
{"alice", "smith", 42, 160.0, "la", "bub", "[email protected]"},
...
{"john", "sdfs", 34, 15.5, "a", "bl", "[email protected]"},
{"joe", "smith", 42, 16.0, "a", "bub", "[email protected]"},
...
...
};
En fin de compte, je besoin d'un tableau 2D pour alimenter mon swing TableModel.
Une idée sur la façon d'accomplir cela? Ça me fait mal à l'esprit maintenant.
Voir cet exemple simple de construction d'un 'TableModel' en utilisant un 'Collection', comme suggéré par @Bill K. http://stackoverflow.com/questions/2541037/i-have-to-select-the-checkbox-two-times- to-check-uncheck-in-jtable/2541265 # 2541265 – trashgod