MediaTracker m_track = new MediaTracker(this); 指applet
        
        Image img = 把你的图片先弄成Image然后
        
        m_track.addImage(img, 0);
        
ImageIcon anotherPic=new ImageIcon(img);
jButton1.setIcon(anotherPic);这样试试

解决方案 »

  1.   

    将所有的控件放到一个实现双缓冲的容器,然后将此容器加入this
    双缓冲容器类代码如下:
    /*
     * @(#)DoubleBufferPanel.java 1.2 97/01/14 Jeff Dinkins
     *
     * Copyright (c) 1995-1997 Sun Microsystems, Inc. All Rights Reserved.
     *
     */
     
    import java.awt.*;
    import java.applet.*;public class DoubleBufferPanel extends Panel {
        
      Image offscreen;  /**
       * null out the offscreen buffer as part of invalidation
       */
      public void invalidate() {
          super.invalidate();
          offscreen = null;
      }  /**
       * override update to *not* erase the background before painting
       */
      public void update(Graphics g) {
          paint(g);
      }  /**
       * paint children into an offscreen buffer, then blast entire image
       * at once.
       */
      public void paint(Graphics g) {
          if(offscreen == null) {
             offscreen = createImage(getSize().width, getSize().height);
          }      Graphics og = offscreen.getGraphics();
          og.setClip(0,0,getSize().width, getSize().height);
          super.paint(og);
          g.drawImage(offscreen, 0, 0, null);
          og.dispose();
      }}