Hallo
mein Programm wirft hier eine NullPointerException ich weiss aber nicht warum?
Dass bild ist nicht null dass hab ich schon raus;
Danke im vorraus:toll:
mein Programm wirft hier eine NullPointerException ich weiss aber nicht warum?
Dass bild ist nicht null dass hab ich schon raus;
Java:
BufferedImage draw;
Graphics g=frame.getGraphics();
switch(random.nextInt(5)){
case 0:{
draw=loadPics("pics/Picture1.jpg",1)[0];
g.drawImage(draw,(this.getWidth()/2)-(draw.getWidth()/2),
(this.getHeight()/2)-(draw.getHeight()/2),null);
break;
}
}
private BufferedImage[] loadPics(String path,int pics){
BufferedImage[] anim=new BufferedImage[pics];
BufferedImage source=null;
URL pic_url=getClass().getClassLoader().getResource(path);
try{
source=ImageIO.read(pic_url);
}catch(IOException e){}
for(int cnt=0;cnt<pics;cnt++){
anim[cnt]=source.getSubimage(cnt*source.getWidth()/pics,0,
source.getWidth()/pics,source.getHeight());
}
return anim;
}
Danke im vorraus:toll: