Java Applet 清除屏幕

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12271732/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 08:16:36  来源:igfitidea点击:

Java Applet Clear Screen

javaappletscreenclear

提问by CodeKingPlusPlus

For Java Applets, what is the best method of "clearing the screen"? Is there a particular function or would you create and paint a white rectangle the size of the screen?

对于 Java Applets,“清屏”的最佳方法是什么?是否有特定的功能,或者您会创建并绘制一个屏幕大小的白色矩形?

What are the best practices for the purpose of clearing the entire applet screen?

清除整个小程序屏幕的最佳做法是什么?

回答by Roman C

Usually the best practices of clearing applet will be painting background

通常清除小程序的最佳做法是绘制背景

Dimension d = getSize();
g.setColor(Color.WHITE);
g.fillRect(0, 0, d.width, d.height);