简体   繁体   中英

What is the difference between the paint and draw methods in Java Applets?

I just want to know why both the paint and draw methods are used in Java Applet creation. What is the difference between them?

paint() : Whenever there is a change in the state of the applet on the screen, paint() is called, paint() is also immediately called after start() method.

draw() : And it has methods like drawRect(), drawImage() drawOval() related to Graphics class.

When an applet is placed on a Web page, it is assigned a rectangular area on the page. It is the job of the applet to draw the contents of that rectangle.Similarly, when an applet needs to be drawn, the Web page calls the paint() routine of the applet.But there is no draw() method in applet.When you want to draw something, you should use Graphics class for example Graphics.drawLine(), Graphics.drawOval(), etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM