我也是初学者,你忘了两个变量声明,
而且我没找到你调用的方法(BufferedImage)createImage(300,400);
所以我直接用的构造器,调试成功!
  int i,j; public huahua()
{
setLayout(new FlowLayout());
setSize(300,300);
t = new Thread(this);
t.start();
image=new BufferedImage(300,400,BufferedImage.TYPE_INT_RGB);
g=image.createGraphics();
}

解决方案 »

  1.   


    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;public class huahua
        extends Frame
        implements Runnable
    {
        Thread t;
        BufferedImage image;
        Graphics2D g;
        int i,j;    public huahua()
        {
            setLayout(new FlowLayout());
            setSize(300, 300);
            setVisible(true);
            t = new Thread(this);
            t.start();
            image = (BufferedImage) createImage(300, 400);
            g = image.createGraphics();
        }    public void paint(Graphics gg)
        {
            Graphics2D ggg;
            ggg = (Graphics2D) gg;
            g.fillRect(23, 55, i + 100, j + 100);
            ggg.drawImage(image, 0, 0, this);
        }    public void run()
        {
            while (true)
            {
                try
                {
                    Thread.sleep(200);
                }
                catch (InterruptedException e)
                {}
                if (i == 200)
                {
                    i = 0;
                }
                i++;
                if (j == 200)
                {
                    j = 0;
                }
                j++;
                repaint();
            }
        }    public static void main(String args[]) throws Exception
        {
            new huahua();
        }
    }
      

  2.   

    1.i,j需要声明。
    2.createImage(300, 400);需要在组件显示之后调用。