How to close all child frames from parent frame?

393 views Asked by At

I am now working with an application. In that there are lots of child JFrame objects there. Each time the button to show child frame is clicked a new instance of child frame is created and hence multiple copies of same child frame is created.

How can I prevent multiple copies of child node?

2

There are 2 answers

0
brb tea On BEST ANSWER

You need to track whether child frame has already opened with button click. If it is, then dont create new form. If not create new child form and display it.

Or if your bussiness logic permits then, go for model dialogs. But better you ask your manager.

And as manoj pointed out, you can use boolean data types to flag displaying new form.

3
ManojP On

You can have boolean flag to store jframe state. Based on this flag u can prevent of creating multiple instance of JFrame.