简体   繁体   中英

JAVA Container and Component interaction

So in JAVA, given that a Container can also be called as a component. Why cant i put a JFrame (Container) inside another JFrame (Container/component)?

Yes, you can put a container inside of another container.

That is extremely common, one of the core principles of the component/container hierarchy and quite essential to build any kind of non-trivial UI.

However

  • every component can have only one (direct) container. If you add it to a second one, it will be removed from its original container.

  • JFrame is a top-level container. It cannot be contained in other containers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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