public void paint(Graphics g)
    {
        Dimension d=getSize();
        he=d.height;
        wi=d.width;
        midx= wi >> 1;
        midy= he >> 1;
        Mars.midx=midx;
        Mars.midy=midy;
        if (Main.doubleBuffering)
        {
            if (wi!=bufwi || he!=bufhe)
            {
                if (bufg!=null)
                    bufg.dispose();
                buf=null;
                bufg=null;
            }
            if (buf==null)
            {
                if (wi<=0 || he <=0)
                    return;
                bufwi=wi;
                bufhe=he;
                buf=createImage(wi,he);
                bufg=buf.getGraphics();
            }
        }
        else  //no double buffering
        {
            bufwi=wi;
            bufhe=he;
            bufg=g;
        }
        bufg.setColor(backColor);
        bufg.fillRect(0,0,bufwi,bufhe);

        Mars.drawCube(bufg);
        Mars.drawSolid(bufg);
        Mars.drawStars(bufg);

        if (Main.doubleBuffering)
        {
            g.drawImage(buf,0,0,null);
            if (Main.recordCanvas)
            {
                Main.createImage();
            }
        }

    }