DannyD
DannyD

Reputation: 2901

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. Can this be done.

Upvotes: 0

Views: 60

Answers (1)

Jeffrey
Jeffrey

Reputation: 44808

No, you cannot add any Window to another component, doing so results in a RuntimeException. What you can do is add the contentPane from the JFrame to your JPanel.

Upvotes: 1

Related Questions