在 Swing 中,子级 JComponent
是否可以在其父级 JComponent
的边界之外呈现,或者子级是否始终被限制在其父级的边界内?
最佳答案
只要子组件是轻量级组件,它就会被限制在父组件的边界内。但是,如果它太大,它会被切割,不会做缩放。
如果子组件是重量级组件而父亲组件是轻量级组件,则子组件将在父组件边界之外呈现。
这里有一篇关于此的非常好的文章:http://java.sun.com/developer/technicalArticles/GUI/mixing_components/index.html (不记得是谁推荐给我的,但谢谢!)
我不知道的另一个更新(在链接中):
As of the JDK 6 Update 12 and JDK 7 build 19 releases, it is now possible to seamlessly mix heavyweight and lightweight components within the same container.
关于java - Swing : Can children exceed the bounds of their parent?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6090886/