如何做漆()工作 [英] how does paint() work

查看:187
本文介绍了如何做漆()工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能告诉我到底怎么做的paint()方法的Java小程序的工作,用通俗的话?喜欢,什么时候会被调用,怎么会叫?因为有时它被称为多次,我不知道怎么发生这种情况。

Can anyone tell me exactly how does the paint() method in java applet work, in simple words? Like, when it will be called , how it will be called? Because sometimes it gets called multiple times and I do not know how that happens.

推荐答案

要理解这一点,你需要知道Applet的生命周期。

To understand this you need to know Applet Lifecycle..

一个applet的生命周期:

Life Cycle of an Applet:

四种方法Applet类给你,你建立任何严重的小应用程序的框架:

Four methods in the Applet class give you the framework on which you build any serious applet:

1)初始化:此方法适用于需要对您的小程序初始化什么。 Applet标记内的param标签已被处理后,它被称为

1) init: This method is intended for whatever initialization is needed for your applet. It is called after the param tags inside the applet tag have been processed.

2)启动:浏览器调用init方法后,此方法是自动调用。每当用户在经历了到其他页面后返回到包含applet的页面,也称为

2) start: This method is automatically called after the browser calls the init method. It is also called whenever the user returns to the page containing the applet after having gone off to other pages.

3)停止:当用户关闭移动在其上的小程序位于页面后,此方法是自动调用。它可以,因此,反复在同一小程序调用。

3) stop: This method is automatically called when the user moves off the page on which the applet sits. It can, therefore, be called repeatedly in the same applet.

4)破坏:当浏览器正常关闭此方法仅调用。由于小程序是为了住在HTML页面中,你不应该离开,通常在用户离开包含Applet页面后之后的资源。

4) destroy: This method is only called when the browser shuts down normally. Because applets are meant to live on an HTML page, you should not normally leave resources behind after a user leaves the page that contains the applet.

5)漆:在start()方法后立即调用,也随时需要的applet重绘自己在浏览器中。在paint()方法实际上是从java.awt中继承。

当paint()方法调用genereted第二种情况是,当程序调用重绘()或update()。
重绘()方法是一个接一个程序来做绘图调用。他们有4个版本,这种方法的,但不带参数的一个通常使用。通过重绘()绘制最常发生在响应于用户输入

The second case, when paint() calls are genereted is when the program calls repaint() or update(). The repaint() method is the one invoked by a program to do drawing. Their are 4 versions of this method but the one with no arguments is usually used. Drawing via repaint() most often takes place in response to user input.

重绘()==>更新()==(通常称)==>漆()

重绘()没有()直接调用油漆。它调度到中间方法的调用,更新()。最后,更新()调用paint()(除非您替换更新)。

repaint() does not invoke paint() directly. It schedules a call to an intermediate method, update(). Finally, update() calls paint() (unless you override update).

这篇关于如何做漆()工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆