java awt 双缓冲技术 (复制代码)

  /**
     * java awt双缓冲技术  复制代码到显示区
     */
 Image offScreenImage = null;
    
    public void update(Graphics g) {
        if(offScreenImage == null) {
            offScreenImage = this.createImage(屏幕宽, 高);
        }
        Graphics gOffScreen = offScreenImage.getGraphics();
        Color c = gOffScreen.getColor();
        gOffScreen.setColor(Color.GREEN);
        gOffScreen.fillRect(0, 0,屏幕宽, 高);
        gOffScreen.setColor(c);
        paint(gOffScreen);
        g.drawImage(offScreenImage, 0, 0, null);
    }
    

 

posted @ 2018-01-10 18:04  yoyo198212  阅读(946)  评论(0编辑  收藏  举报