I'm pretty new to Java and I've tried looking this up but couldn't really find any thing that helped. I'm wondering how I could detect when a specific window is closed? I've been using windowClosing() but this applies to any window that is closed, and so the event that I would want to happen as a result of window A closing also happens if window B closes. How do I go about detecting only if window A is closed? Sorry if this is worded badly, I don't know that much Java terminology. Thanks in advance :)
package gui_login;
//awt classes
import java.awt.FlowLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
//swing classes
import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.JPasswordField;
import javax.swing.JOptionPane;
import javax.swing.JButton;
public class windowtest implements ActionListener, WindowListener
{
//get JFrame
    JFrame JFrame = new JFrame();
    public static JFrame frameA = new JFrame("FrameA");
    public static JFrame frameB = new JFrame("FrameB");
    static windowtest windowtest = new windowtest();
public static void main(String[] args) 
{
    windowtest.frames();
}
public void frames()
{
    frameA.setLayout(new FlowLayout());
    frameA.setSize(220, 130);
    frameA.setVisible(true);
    frameA.addWindowListener(this);
    frameB.setLayout(new FlowLayout());
    frameB.setSize(220, 130);
    frameB.setVisible(true);
    frameB.addWindowListener(this);
}
public void windowClosing(WindowEvent e) {
    System.out.println("Yo");
}
public void windowActivated(WindowEvent e) {
}
public void windowClosed(WindowEvent e) {
}
public void windowDeactivated(WindowEvent e) {
}
public void windowDeiconified(WindowEvent e) {
}
public void windowIconified(WindowEvent e) {
}
public void windowOpened(WindowEvent e) {
}
public void actionPerformed(ActionEvent e) {
}
}
 
    