How one JFrame can know the status of other Jframe?

228 Views Asked by At

As the title say, I actually want to know how one JFrame form can know the windowListening status of other JFrame form.

Might it be confusing, but I can clarify it.

I have a main JFrame form which call 2 other JFrame form. So whenever one JFrame form get closed, it call back the main JFrame form to setVisible(true) and set itself dispose().

But I want to know the status of each other JFrame form individually. All I want is:

  1. If my 1st JFrame is closed, it shud check other JFrame status. If that other JFrame is Activated, then the main JFrame form will not be called. If the other JFrame is Closed or already disposed(), then it shud call the main JFrame to setVisible(true).

I hope u get it. Can someone plz help me to get thru this.

Thanks in Advance.

See: All three JFrame forms are in same package. I'm a newbie in java, so excuse my writing notations. :p

1

There are 1 best solutions below

4
On

Make (2) singleton JFrame classes e.g. public class JFrame1 extends JFrame {}. Then you can always call JFrame1.getInstance().isClosed() or whatever you wish. If you're unsure how this would work, google 'java singleton design pattern' =)