sách gpt4 ai đã đi

Java重绘()/更新()

In lại 作者:行者123 更新时间:2023-12-01 05:28:39 33 4
mua khóa gpt4 Nike

只是在编写一些与 java 图形相关的代码,这是我今天的讲座中的非常简单的示例。不管怎样,互联网似乎说更新不会被系统触发器调用,例如调整框架大小等。在这个例子中,更新是由这样的触发器调用的(因此当我只期望调用paint时,会调用update和paint) )。他似乎将其归因于操作系统以及每个操作系统的不同结果。

有人可以帮我澄清一下吗?

在 Windows 7 上工作

Cảm ơn trước

1 Câu trả lời

这是一篇精彩的文章,真正说明了一切:

http://java.sun.com/products/jfc/tsc/articles/painting/

1) Painting in AWT

To understand how AWT's painting API works, helps to know what triggers a paint operation in a windowing environment. In AWT, there are two kinds of painting operations: system-triggered painting, and application-triggered painting.

2) System-triggered Painting

In a system-triggered painting operation, the system requests a component to render its contents, usually for one of the following reasons:

  • The component is first made visible on the screen.

  • The component is resized.

  • The component has damage that needs to be repaired. (For example, something that previously obscured the component has moved, and a previously obscured portion of the component has become exposed).

3) App-triggered Painting

In an application-triggered painting operation, the component decides it needs to update its contents because its internal state has changed. (For example,. a button detects that a mouse button has been pressed and determines that it needs to paint a "depressed" button visual).

4) The Paint Method

Regardless of how a paint request is triggered, the AWT uses a "callback" mechanism for painting, and this mechanism is the same for both heavyweight and lightweight components. This means that a program should place the component's rendering code inside a particular overridden method, and the toolkit will invoke this method when it's time to paint.

关于Java重绘()/更新(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9370232/

33 4 0
行者123
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com