0

i have alot of forms , when i press in button that's open the other form in new one
how i can make it open in the same form & not open it in new one

3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by WargRider
0

you have to have nested JFrames. I am assuming you are wanting to do something like photoshop, where a new document is made, but it is just a floating form inside the photoshop window. For that, you have to add the JFrame of the form you want to open, into the contentPane of the current or (master) JFrame. So if I have 2 frame, frame1 being the main, frame2 is what the button opens, in the button action listener, do this:

fram1.getContentPane().add(frame2);

Make sure frame2 has proper bounds set using frame2.setBounds(params); Also, make sure that frame1 has a proper layout, either null or a specific one, if you use null, then your program will use coordinates :). Good luck! Hope this helped!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.