P
painter3
Gast
Code:
/*
public class imageshow extends Canvas {
int x;
int y;
runnth bus;
BufferedImage bufim;
Graphics2D g2d;
/** Creates a new instance of imageshow */
public imageshow(int sx,int sy) {
bufim=new BufferedImage(sx,sy,BufferedImage.TYPE_INT_RGB);
g2d=(Graphics2D) bufim.getGraphics();
x=sx;
y=sy;
bus=new runnth();
bus.start();
}
public Dimension getPreferredSize() {
return new Dimension(x,y);
}
public void stopp(){
bus.interrupt();
}
public void paint(Graphics g) {
g2d.clearRect(0,0,x,y);
g2d.setColor(new Color(23,134,233));
g2d.fillRect(0,0,234,23);
g.drawImage(bufim,0,0,this);
System.out.println("sdf");
}
class runnth extends Thread{
public runnth(){
super();
}
public void run() {
while(!isInterrupted()){
paint(getGraphics());
}
}
}
}
Exception in thread "Thread-2" java.lang.NullPointerException
at main.imageshow.paint(imageshow.java:58)
at main.imageshow$runnth.run(imageshow.java:67)