hi ich möchte mit diesem quellcode einen hintergrund zeichnen:
nur kommt da immer eine NullPointerException. warum?
Mfg Alias_host
Code:
public class schiffeVersenkenNw extends Frame{
Image img;
Graphics g;
Label back;
public schiffeVersenkenNw()throws MalformedURLException {
Label back=new Label();
setLayout(null);
back.setBounds(0,0,550,350);
add(back);
}
public void hintergrund(){
g= back.getGraphics();
img = getToolkit().getImage(("Schiff.gif"));
g.drawImage(img,0,0,back);
}
public static void main(String[] args)throws MalformedURLException {
schiffeVersenkenNw s= new schiffeVersenkenNw();
s.setSize(550,350);
s.setResizable(false);
s.setLocation(100,50);
s.setVisible(true);
try{
Thread.sleep(500);
}
catch(Exception e){}
s.hintergrund();
}
}
Mfg Alias_host