I want to create a 'generic' JPanel
which can be rendered in any of the higher level Window
classes (JFrame
, JDialog
, or JInternalFrame
to be somewhat precise.)
I want to be able to 'clean up' some static values when that window is no longer being rendered on screen. Normally, I would do this with a Window
class (like JFrame
) and simply addWindowListener
with proper windowClosing
or windowClosed
methods during the creation of the JFrame
.
Since I desire any of the Window
classes to be able to render this, I don't even know which kind of listener to add nor do I know which window to add it to.
Is there a way to 'hook' the realization and rendering of the JPanel
to so that I can add my shutdown hooks no matter what Window
class renders it?
(I looked at PropertyChangeListener
, but componentShown
doesn't trigger on the JPanel
rendering.)
Any help would be appreciated.