Appel un object dans Tableau d'objects
lu,
Un exemple sera plus parlant :
La construction :
Code:
1 2 3 4 5 6 7
|
private MesCheck Check_Options1, Check_Options2, Check_Options3,...
private MesCheck[] Check_ListOptions = new MesCheck[]{
Check_Options1,
Check_Options2,
Check_Options3,...}; |
L'utilisation :
Code:
1 2 3 4 5 6 7 8
|
for (int i=0;i<Check_ListOptions.length;i++){
///JE CREE MES CHECK
Check_ListOptions[i] = new MesCheck();
///JE LES INSERE DANS MON JPANEL
MonJPanel.add(Check_ListOptions[i]);
} |
Là ou le problème se pose c'est que j'aimerai pouvoir appeler des méthodes, un peu plus loin, sur certaines "Check", mais pas sur toutes. Sachant que l'ordre est incertain, je ne peux pas mettre en dure un appel comme ceci : Check_ListOptions[2].ma_méthode
Pourtant l'affichage est correcte ; les composants sont bien disposés sur le JPanel.
Exemple qui me retourne un nullpointer :
Code:
1 2 3 4 5
|
Check_Options1.setSelected(true);
Check_Options1.mes_truc(xxxxxxx);
...... |
Merci
@+