简体   繁体   English

Java Applets中的paint和draw方法有什么区别?

[英]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. 我只想知道为什么在Java Applet创建过程中同时使用paint和draw方法。 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. paint() :每当屏幕上的applet状态发生变化时,都会调用paint(),并且在start()方法之后也会立即调用paint()。

draw() : And it has methods like drawRect(), drawImage() drawOval() related to Graphics class. draw() :它具有与Graphics类相关的诸如drawRect(),drawImage(),drawOval()之类的方法。

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. 绘制该矩形的内容是applet的工作。类似地,当需要绘制applet时,Web页面将调用applet的paint()例程。但是applet中没有draw()方法。您想绘制一些东西,应该使用Graphics类,例如Graphics.drawLine(),Graphics.drawOval()等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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