I know how to write a window listener class. But I have always only written one for a single JFrame. Is it possoble to implement window listener in one class and invoke this class on multiple JFrames in one app? I am assuming that the answer to this question is yes, and if so, when I getSource() in the event windowEvent method how do I know which Window/JFrame is active? Do I gain that from the windowActivated() method? Thanks.
yes, u have to use getSource() of WindowEvent in windoActivated() method to get the name of the frame object. however u have to add the WindowListener to each frame instance or inside each frame's constructor. rgds, Shashi
I have successfully achieved what I was trying for. But I have another question and thought I would just post it along with this post since it is related. Is the singleton method safe to use on a WindowListener like this and just create an object reference to the WindowListener object? Or should I just create a new WindowListener object for each individual frame?