i just dont know how to code this very simple situation: i have this first window that has a button which when clicked opens a second window;
this second window has a button that when clicked should close just this window, not the app
You should be using JFrame instance to call it. Its part of Window (I think?) class which gets inherited by JFrame. Also you would have to declare your JFrame reference as final in the CloseWindow class. (final- because the variables being used in the Anonymous Inner class (your ActionListener) must be declared as final)
Don't you think you will have the same problem with the above statement?
The setDefaultCloseOperation would decide what to do with the JFrame when the user clicks on the Close button on the JFrame. I think by default it hides the Frame, but we would usually want to exit the Frame when we click on the Close button.