In java, JFrame is Heavy Weight Component or Light Weight Component?

好久不见. 提交于 2019-12-20 02:09:27

问题


I Know Swing is considered lightweight because it is fully implemented in Java, without calling the native operating system for drawing the graphical user interface components.

On the other hand, AWT (Abstract Window Toolkit) is heavyweight toolkit, as it merely makes calls to the operating system in order to produce its GUI components.

But i heard that Swing is still based on AWT, and even Swing components must have at least one heavyweight container. In other words, JFrame, JApplet are not lightweight.Is it true? Spot your reason?


回答1:


JFrames are heavyweight, since it's impossible to create a task-view-level window in most OS without creating a "heavy" AWT window. Lightweight components can replace internal widgets with java-based stuff that doesn't require JNI calls, but windows are the special case. JFrame does let you do custom renders, though. Also, if you're using other lightweight stuff, then I suggest using JFrame as well since it makes the rendering more efficient overall than mixing light and heavy components.



来源:https://stackoverflow.com/questions/7396878/in-java-jframe-is-heavy-weight-component-or-light-weight-component

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!