Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display JFrame inside JPanel in java

Is this possible to add a JFrame into a JPanel in Java. i m using a java program which is giving output as a frame which i wanted to display inside another program's JPanel on click of a button. How can i do this?

like image 863
Abhishek Patel Avatar asked Feb 20 '12 09:02

Abhishek Patel


2 Answers

Read about JInternalFrame. I think it's the way to go here.

http://docs.oracle.com/javase/tutorial/uiswing/components/internalframe.html

like image 187
thermz Avatar answered Sep 28 '22 05:09

thermz


You could call getContentPane() on the JFrame to extract its main contents as a JPanel (usually) and without the menu bar and decorations, and display that as a JPanel though best would probably be to update the original program so that it produces a JPanel and not a JFrame.

like image 44
Hovercraft Full Of Eels Avatar answered Sep 28 '22 05:09

Hovercraft Full Of Eels