Hello,
If you are using a
Frame (which you probably are), from
the documentation for the class Frame we find that:
Frames are capable of generating the following types of WindowEvents:
WINDOW_OPENED WINDOW_CLOSING WINDOW_CLOSED WINDOW_ICONIFIED WINDOW_DEICONIFIED WINDOW_ACTIVATED WINDOW_DEACTIVATED WINDOW_GAINED_FOCUS WINDOW_LOST_FOCUS WINDOW_STATE_CHANGED
WindowEvent.WINDOW_ICONIFIED is the event that indicates that the window has been minimized. Unfortunately, none of these include just maximizing.
One idea for handling when the
Frame is maximized would be to implement
WindowStateListener (which is "since 1.4" and as such might not be available to you - in which case a slightly different design would be necessary) and every time
windowStateChanged(WindowEvent) is invoked, check whether the state of the
Frame is
Frame.MAXIMIZED_BOTH ("since 1.4"). To get the state of the
Frame use
Frame::getExtendedState() (which, again, is "since 1.4").
Otherwise, perhaps you could simply take advantage of the automatic invocation of
update(Graphics) (which
Frame inherits from
Container) and its default behavior of invoking
paint(Graphics). Perhaps you could override either one of these methods and perform your checks and subsequent invocation of your method.
If you're using a JDK (or JRE) "pre 1.4", then perhaps an easy solution would be to use
Toolkit.getDefaultToolkit().getScreenSize() which returns a
Dimension object that describes the size of the user's screen and compare this against the current size of the
Frame.
Well, that's probably enough rambling. Hopefully, something has sparked an idea for you.
Good Luck.
[ April 17, 2002: Message edited by: Dirk Schreckmann ]