I have 1 MAIN-FRAME and 2 INTERNAL-FRAMES(say -> Frame 1
and Frame 2
) in my java netbeans project. To switch from the main-frame to Frame 1, I used the following code IN THE MAIN-FRAME'S CLASS :-
Frame1 frame = new Frame1();
frame.setVisible(true);
jDesktopPane1.add(frame);
setContentPane(jDesktopPane1);
The above code works perfectly fine, thereby creating the frame 1. But the below code WHICH IS IN THE FRAME 1's CLASS does not work unfortunately:-
Frame2 frame2 = new Frame2();
MainFrame mf = new MainFrame();
frame2.setVisible(true);
mf.setContentPane(frame2);
Please tell me where am I going wrong. I am kind of new to java. So, Please be calm if you find this question silly.