WWW

[알림판목록 I] [알림판목록 II] [글목록][이 전][다 음]
[ WWW ] in KIDS
글 쓴 이(By): vertigo (Gandalf)
날 짜 (Date): 1996년01월19일(금) 15시05분42초 KST
제 목(Title): repaint(), paint(), and update() in Java




Java 프로그래밍을 하다보니 (Applet 작성을 하다보니), paint()와 update()가
헷갈리더군요. 관련 뉴스그룹을 보니, 이에 대한 해답이 있는 것 같습니다.
아래에 첨부하니, 참조하세요. 
(정리하면, repaint() 메쏘드는 update()를 콜하고, update() 메쏘드는 화면을 
클리어시키고, 
paint() 메쏘드를 콜합니다. 따라서 에니메이션을 작성하기 위해서는 update()를 
재정의해야
합니다. 그렇지 않으면 *껌벅* *껌벅* 이게 되죠.)


Applet graphics not clearing each time paint() is
called

David Sklar (t-davids@microsoft.com)
Fri, 30 Jun 95 16:45:10 PDT 

How can I tell a simple applet (and/or it's Graphics object) not to 
clear each time paint is called?

i.e. how can I make something simple like the following code from 
having only 1 line get drawn at once....?

class silly extends Applet implements Runnable {
int h = 0;
int v = 0;
int oh = 0;
int ov = 0;

public void init() {
resize(200,200);
}

public void paint(Graphics g) {
g.drawLine(oh,ov,h,v);
}

public void mouseDown(int x, int y) {
oh = h;
ov = v;
h = x;
v = y;
repaint();
}
}



Re: applet graphics not clearing each time
paint() is called

Jonathan Payne (jpayne@flim@Sun.COM)
Sat, 1 Jul 1995 18:41:32 -0700 

Override the update(Graphics g) method. It's called whenever you
ask for an update with the ... hmm, is it repaint() method? Anyway,
thge defaul;t implementation of update(Graphics g) is to clear the
background and call the paint(Graphics g) method.


paint(Graphics g) is called whenever the applet scrolls into view, or,
the entire window is painted because it's exposed, etc.

 
===============================================================================
                    I am just a Hippie living in 1990s
                        !Turn On Your Love Night!
                    All men are equal in their madness!
===============================================================================
[알림판목록 I] [알림판목록 II] [글 목록][이 전][다 음]
키 즈 는 열 린 사 람 들 의 모 임 입 니 다.