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.
本文探讨了Swing中的轻量级组件与AWT中的重量级组件之间的关键区别,特别是它们在层级布局上的不同表现。文章强调了在同一个容器中混合使用这两种类型组件时可能遇到的问题,并提供了一些重要的指导原则。


被折叠的 条评论
为什么被折叠?



