希望与大家分享经验。
package com.borland.samples.welcome;
import java.awt.*;
public class mypanel extends panel {
private image bi; // offscreen image
private graphics big; // graphics for the offscreen image
public void update(graphics g) {
paint(g);
}
public void paint(graphics g) {
if (bi == null) { // you cant do this from the constructor
bi = createimage(getsize().width,getsize().height);
big = bi.getgraphics();
}
rectangle area = g.getclipbounds(); // this is the area that needs to be (re)painted (no need to repaint everything)
big.setclip(area);
big.clearrect(area.x, area.y, area.width, area.height); // fills the area with the background color // the next statement will call the paint methods for the other panels/components you have added to this panel // and draw them to the offscreen image
super.paint(big);// now draw the offscreen image to the panel
g.drawimage(bi,area.x, area.y, area.x+area.width, area.y+area.height,area.x, area.y, area.x+area.width, area.y+area.height,this);
}
}
文章整理:西部数码--专业提供域名注册、虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!


