简体   繁体   English

是否可以在Java中将JFrame添加到JPanel?

[英]Is it possible to add a JFrame to a JPanel in java?

I have been working on a series of JPanel and I wanted to add a JFrame from another class to one of my panels. 我一直在研究一系列JPanel,我想将另一个类的JFrame添加到一个面板中。 Can this be done. 可以做到这一点。

No, you cannot add any Window to another component, doing so results in a RuntimeException . 不,您不能将任何Window添加到另一个组件,这样做会导致RuntimeException What you can do is add the contentPane from the JFrame to your JPanel . 您可以做的是将JFramecontentPane添加到您的JPanel

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

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