Qualcuno saprebbe spiegarmi perchè nello spezzone di codice sotto postato ogni tanto, randomicamente mi genera questo errore?
Errore:
codice:Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at javax.swing.JComponent._paintImmediately(JComponent.java:5067) at javax.swing.JComponent.paintImmediately(JComponent.java:4862) at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:727) at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:683) at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:663) at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:128) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) at java.awt.EventQueue.dispatchEvent(EventQueue.java:597) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160) at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
il codice invece:
il programma esegue solo questo public, che in pratica non fa altro che creare un frame, un pannello e aggiungerci l'immagine del banner, presa da un xml (queste parti sono gia gestite)codice:public void disegnaBanner(int PosX,int PosY,int larghezza,int altezza){ int idVisBan=0; int totBan=0; int contatore=0; int numBn=0; for(int s=0;s<myRetBan.arrayBanner.length;s++){ idVisBan=Integer.parseInt(myRetBan.arrayBanner[s][0]); if(idVisBan==Integer.parseInt(myRetConf.arrayConf[0][0])){ totBan++; }//chiude if id vis spo }//chiude for arrayNameB=new String[totBan]; for(int i=0;i<myRetBan.arrayBanner.length;i++){ idVisBan=Integer.parseInt(myRetBan.arrayBanner[i][0]); if(idVisBan==Integer.parseInt(myRetConf.arrayConf[0][0])){ arrayNameB[contatore]=myRetBan.arrayBanner[i][2]; contatore++; } } for(int s=0;s<myRetBan.arrayBanner.length;s++){ idVisBan=Integer.parseInt(myRetBan.arrayBanner[s][0]); System.out.println("idVisBan vale "+idVisBan); System.out.println("idMids vale "+myRetConf.arrayConf[0][0]); if(idVisBan==Integer.parseInt(myRetConf.arrayConf[0][0])){ jPannello.removeAll(); MonitorObj.disegnaImages(jPannello, "./Banner/"+arrayNameB[numBn], 0, 0, larghezza, altezza); System.out.println("Disegno "+arrayNameB[numBn]); permanenza=Integer.parseInt(myRetBan.arrayBanner[numBn][3])*1000; if(iFlag==0){ iFlag=1; MonitorObj.creaFinestra(framePrincipale, jPannello, PosX, PosY, larghezza, altezza); framePrincipale.add(jPannello); framePrincipale.doLayout(); framePrincipale.setVisible(true); System.out.println("DISEGNATO"); System.out.println("__________________________________"); } else{ //valido il pannello modificato jPannello.validate(); //ridisegno il pannello jPannello.repaint(); //lo aggiungo al frame principale framePrincipale.add(jPannello); //valido il frame principale framePrincipale.validate(); //ridisegno il framePrincipale framePrincipale.repaint(); System.out.println("DOPO REPAINT"); System.out.println("__________________________________"); } numBn++; try { System.out.println("permanenza vale "+permanenza); tskBan.sleep(permanenza); L'errore mi nasce qui, ovvero mentre il thread è in sleep System.out.println("__________________________________"); } catch (InterruptedException ex) { try { flog.scriviLog(1, "Thread Banner Interrotto " + ex.getMessage()); } catch (FileNotFoundException ex1) { Logger.getLogger(TaskSponsor.class.getName()).log(Level.SEVERE, null, ex1); } catch (IOException ex1) { Logger.getLogger(TaskSponsor.class.getName()).log(Level.SEVERE, null, ex1); } } }//chiude if id vis spo }//chiude for }
se mando in esecuzione l'errore mi nasce nel punto indicato!
Qualcuno può darmi una mano?

Rispondi quotando