简体   繁体   English

JFrame的重量轻吗?

[英]How JFrame is light weight?

JFrame is Extending Frame. JFrame是扩展框架。 Then, How JFrame is lightweight but Frame is heavyweight? 那么,JFrame如何轻量级而Frame却重量级?

I red this article but still i didn't get how JFrame achieves its lightweight property? 我写了这篇文章,但仍然不明白JFrame是如何实现其轻量级属性的?

I got from here that JFrame is heavyweight but other Components starts with J* are lightweight. 我从这里了解到JFrame是重量级的,但其他以J *开头的组件都是轻量级的。 How other Swing components achieves this. 其他Swing组件如何实现这一目标。 I need bit of technical details. 我需要一些技术细节。

Technically it's not. 从技术上讲不是。 Both are heavy weight components, but because JFrame has been setup to support the JRootPane , which contains the content pane (and possibly) the glass pane (as well as the JMenuBar ), it is consider "light weight", because it's been deliberately configured to support light weight components 两者都是重量级的组件,但是由于JFrame已设置为支持JRootPane ,它包含内容窗格(可能还包含玻璃窗格)(以及JMenuBar ),因此它被认为是“轻量级的”,因为它是经过精心配置的支持重量轻的组件

Essentially JFrame and JWindow have been modified as light weight containers that support light weight components 本质上, JFrameJWindow已被修改为支持轻量组件的轻量容器

it is still a heavyweight component because it(JFrame) inherits from the Frame.And it is not belong to the JComponents which is lightweight components. 它仍然是重量级的组件,因为它(JFrame)从Frame继承而来,并且不属于轻量级组件JComponents。

Heavyweight means each Java component has a native peer associated with it. 重量级意味着每个Java组件都有一个与其关联的本机对等体。 A native peer is an OS-specific component... AWT is heavyweight, so if you create a AWT Button, on the Windows platform an MFC button is created, on *nix a Motif button is created, etc. 本机对等体是特定于OS的组件... AWT非常重,因此,如果创建AWT按钮,则在Windows平台上会创建MFC按钮,在* nix上会创建Motif按钮,依此类推。

Lightweight means that there is not a native peer associated with the java component. 轻量级意味着没有与Java组件关联的本地对等体。 This is done by having only the top-level component be heavyweight and all the lightweight components are drawn on to it. 这是通过仅使顶层组件具有重量级并将所有轻量级组件绘制到上面来完成的。 Swing is lightweight. 秋千很轻。

Of course, AWT and Swing are specific to standard Java (J2SE). 当然,AWT和Swing特定于标准Java(J2SE)。 Under J2ME it depends on what sort of device you are using. 在J2ME中,这取决于您使用的设备类型。 If you are using a more powerful device, like the Sharp Zaurus, then you have AWT and functionality pretty close to J2SE levels. 如果使用的是Sharp Zaurus等功能更强大的设备,那么您的AWT和功能就非常接近J2SE级别。 If you have something like a Java-Enabled cell phone, you don't have all the capabilites that you need for a fully featured GUI, so there are special libraries used for making these applications. 如果您拥有支持Java的手机,则没有具备功能齐全的GUI所需的所有功能,因此有一些特殊的库可用于制作这些应用程序。 You'd need to look at the APIs provided by the device manufacturer most probably. 您最有可能需要查看设备制造商提供的API。

JFrames are heavyweight , since it's impossible to create a task-view-level window in most OS without creating a "heavy" AWT window. JFramesheavyweight ,因为要在大多数OS中创建任务视图级窗口,而又不创建“沉重的” AWT窗口是不可能的。 Lightweight components can replace internal widgets with java-based stuff that doesn't require JNI calls, but windows are the special case. Lightweight组件可以用不需要JNI调用的基于Java的东西替换内部小部件,但是windows是特例。 JFrame does let you do custom renders, though. JFrame确实允许您执行自定义渲染。 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. 另外,如果您正在使用其他轻量级的东西,那么我建议您也使用JFrame ,因为与混合轻量级组件和重度组件相比,它使渲染总体上更高效。

It is still a heavyweight component because it (JFrame) inherits from the Frame . 它仍然是重量级组件,因为它(JFrame)继承自Frame And it is not belong to the JComponents which is lightweight components . 而且它不属于lightweight components JComponents

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

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