Z-order:One difference between lightweight and heavyweight components

来源:互联网 发布:网络空间治理 网警 编辑:程序博客网 时间:2024/05/18 01:47

Swing components are referred to as lightweights while AWT components are referred to as heavyweights. One difference between lightweight and heavyweight components is z-order: the notion of depth or layering. Each heavyweight component occupies its own z-order layer. All lightweight components are contained inside heavyweight components, and they maintain their own layering scheme as defined by Swing. When you place a heavyweight inside another heavyweight container, it will, by definition, overlap all lightweights in that container.

What this ultimately means is that you should avoid using both heavyweight and lightweight components in the same container whenever possible. The most important rule to follow is that you should never place heavyweight components inside lightweight containers that commonly support overlapping children. 

原创粉丝点击