I have a class named NetPosition which has a JFrame and that JFrame contains a button which if clicked makes object of another class called BuyScreen and opens another JFrame.THe problem is when the parent frame is closing i want all the BuyScreen frames to be closed.Something like this
frame.addWindowListener(new WindowListener() {
    @Override
    public void windowOpened(WindowEvent e) {
        // TODO Auto-generated method stub
    }
    @Override
    public void windowIconified(WindowEvent e) {
        // TODO Auto-generated method stub
    }
    @Override
    public void windowDeiconified(WindowEvent e) {
        // TODO Auto-generated method stub
    }
    @Override
    public void windowDeactivated(WindowEvent e) {
        // TODO Auto-generated method stub
    }
    @Override
    /*Closing all the buy screens and sells screens of marketwatch before market watch screen is closed*/
    public void windowClosing(WindowEvent e) {
        // TODO Auto-generated method stub
        if(BuySellNetPosition.countBuySellNetPosition!=0)
        {
            BuySellNetPosition.frame
        }
    }
    @Override
    public void windowClosed(WindowEvent e) {
        // TODO Auto-generated method stub
    }
    @Override
    public void windowActivated(WindowEvent e) {
        // TODO Auto-generated method stub
    }
});
The child frame is not static.I can have several BuyScreen frames opened at the same time.Is it possible to close all frames of a particular class without knowing the names of references to that class. Previously i made an array of BuyScreen objects to handle this problem.But i am wondering if there is another way.
 
     
     
    