0
자바로 처음으로 애플릿을 만들고, 두 개의 튜토리얼을 읽고 이중 버퍼링을위한 다양한 솔루션을 찾았습니다. 나는 그들 사이의 차이점, 장단점 등이 무엇인지 알고 싶습니다. 미리 감사드립니다! 먼저 하나이중 버퍼링 방법의 차이점
: 하나
public void update(Graphics g) {
if (offImage == null) {
offImage = createImage(this.getWidth(), this.getHeight());
offGraphics = offImage.getGraphics();
}
offGraphics.setColor(getBackground());
offGraphics.fillRect(0, 0, getWidth(), getHeight());
offGraphics.setColor(getForeground());
paint(offGraphics);
g.drawImage(offImage, 0, 0, this);
}
둘째 :
public void init() {
offImage = createImage(getWidth(), getHeight());
offGraphics = offImage.getGraphics();
}
public void paint(Graphics g) {
g.drawImage(offImage,0,0,this);
}
public void update(Graphics g) {
paint(g);
}