Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

function paint will be executed twice? 1

Status
Not open for further replies.

jslmvl

Vendor
Jan 26, 2008
268
GB
Hi,

This very simple code shows function paint will be executed twice, why?

import java.applet.*;
import java.awt.*;
public class TestClass extends Applet{
int k=0;
public void paint(Graphics g){
g.drawString(Integer.toString(++k),50,20);
}
}
 
Paint method is called whenever the component needs to be redrawn. Take a look at this

Cheers,
Dian
 
Thank you, Dian.
I am reading the link you suggested, a little too difficult for me though.
 
When you move the window, for example, it needs to be repainted, Then, AWT calls the paint method of each component. That's the basic idea.

Cheers,
Dian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top