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

What do you mean by a "form"? Is it a window?

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:


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!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.