2

I am using NetBeans. I have to make two JFrames in separate files such as test1.java and test2.java. test1 is a simple registration form and test2 is a webcam application that captures an image.

I want to show the test2 JFrame in the Test1 JFrame. How can I do this?

Darshan Rivka Whittle
  • 32,989
  • 7
  • 91
  • 109
Jayashri
  • 366
  • 4
  • 13
  • 25

2 Answers2

1

I believe what you want is called a JInternalFrame, and is a separate component than a JFrame.

Look here for an explanation of internal frames

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

You should be able to change your test2 frame into an internal frame to get the behavior you want.

skynet
  • 9,898
  • 5
  • 43
  • 52
1

What I did was create a whole new class that makes it own GUI. I did not add a main method, I just called it something else. And when I wanted that GUI page to pop up, I just called it with your usual Page page = new Page() method. There was one other thing that I did. Instead of the typical setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); I used setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); so that the whole thing does not exit when you hit the red X, it just gets rid of the window, and lets the other one stay open

The_Steve13
  • 119
  • 2
  • 11