bom dia pessoal tudo bom??
pessoal e o seguinte, tenho um array de booleanos, e um array de JLabels, quanto o array de booleanos da posição 0 estiver setado como true, gostaria q o array de Jlabels da posição 0 tivesse o texto setado como “Ativado”.
fiz desse jeito aqui o:
//array de Labels
private javax.swing.JLabel[] LabelArray = new javax.swing.JLabel[] { Lstats1, Lstats2,
Lstats3, Lstats4, Lstats5, Lstats6, Lstats7, Lstats8, Lstats9, Lstats10, Lstats11, Lstats12,
Lstats13, Lstats14, Lstats15, Lstats16, Lstats17, Lstats18, Lstats19, Lstats20,
Lstats21, Lstats22, Lstats23, Lstats24, Lstats25, Lstats26, Lstats27, Lstats28,
Lstats29, Lstats30, Lstats31, Lstats32, Lstats33, Lstats34, Lstats35, Lstats36,
Lstats37, Lstats38, Lstats39, Lstats40};
//poling de envio periodico
public void run() {
//troca o valor do texto do JLabel
while(true) {
for(int i = 0; i < 40; i++) {
if (ioStatsS[i] == true) {
LabelArray[i].setText("Ativado");
} else{
LabelArray[i].setText("Desativado");
}
}
try {
Thread.sleep(250);
switch(SendMsg) {
case mIdent :
WriteToPortI();
break;
case mSaidaS :
WriteToPortS();
break;
case mSaidaW :
WriteToPortW(ioStatsW);
break;
case mEntrada :
SendMsg = FrameMsg.mEntrada;
WriteToPortE();
break;
default :
SendMsg = FrameMsg.mIdent;
}
} catch (InterruptedException ex) {
Logger.getLogger(AeSManutenção.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
mas ele da um erro de null pointer exception:
Exception in thread "Thread-4" java.lang.NullPointerException
at AeSManutenção.run(AeSManutenção.java:20)
at java.lang.Thread.run(Thread.java:619)
alguem poderia me ajudar??
desde jah agradeço.