你用的是覆盖update方法
解决方法是用双缓冲区来绘图,就是先建立一个Graphics对象,在这个对象上画图,然后往客户端发送,不仅可以减少闪烁,也可以解决你的问题

解决方案 »

  1.   

    这是 Applet 天生的毛病
    解决方法可以是 不停的重画当然 采用双缓冲是解决闪烁的办法
      

  2.   

    to telenths(.缓冲溢出.) 
     
    就是说如果不是不停的重画,只用双缓冲是不能解决被覆盖就消失的问题了吗?
      

  3.   

    绘图代码写在public void paint(Graphics g)函数中,否则会刊不到希望的结果的。就如VC不写在OnDraw或OnPaint中一样的。
      

  4.   

    Applet程序运行有一定的顺序,当第一次运行的时候,执行init()--paint()
    当当前窗口关闭了,重新看窗口时,就调用start()
      

  5.   

    这确实是因为覆盖了updata方法产生的问题,有解决的办法吗?
      

  6.   

    两种方法:
    1,覆盖UPDATE(),要么要本不清屏,要么只清除屏幕的改变部分(要求算法精确)
    2,既覆盖UPDATE(),也覆盖PAINT(),且使用双缓冲
      

  7.   

    能不能详细点,小弟接触AWT时间不长
    我是这样写update()和paint()的:public synchronized void update(Graphics g) {
        Dimension d = getSize();
        if ((offscreen == null) || (d.width != offscreensize.width) || (d.height != offscreensize.height)) {
    offscreen = createImage(d.width, d.height);
    offscreensize = d;
      if (offgraphics != null) {
        offgraphics.dispose();
    }
    offgraphics = offscreen.getGraphics();
    offgraphics.setFont(getFont());
        }
        offgraphics.setColor(getBackground());
        offgraphics.fillRect(0, 0, d.width, d.height);
        FontMetrics fm = offgraphics.getFontMetrics();
        paint(offgraphics);
        g.drawImage(offscreen, 0, 0, null);
    }public void paint(Graphics g) {
        g.drawRect(....);
    }怎样改进???
      

  8.   

    public synchronized void update(Graphics g) {
        Dimension d = getSize();
        if ((offscreen == null) || (d.width != offscreensize.width) || (d.height != offscreensize.height)) {
    offscreen = createImage(d.width, d.height);
    offscreensize = d;
      if (offgraphics != null) {
        offgraphics.dispose();
    }
    offgraphics = offscreen.getGraphics();
    offgraphics.setFont(getFont());
        }
        offgraphics.setColor(getBackground());
        offgraphics.fillRect(0, 0, d.width, d.height);
        FontMetrics fm = offgraphics.getFontMetrics();
        paint(offgraphics);
        g.drawImage(offscreen, 0, 0, null);
    }public void paint(Graphics g) {
        g.drawRect(....);
    }
    public void start()
    {
       g.drawRect(....);
    }
      

  9.   

    我这样加的:public void start()
    {
       Graphics g = getGraphics();
       g.drawRect(....);
    }也还是不行!
      

  10.   

    public void start()
    {
       repaint();
      
    }
    试一下!